• Halloween is coming! To celebrate the occasion, we dusted off a couple of old skins, and even created a brand new one (Pixel).
    To get into the festive spirit, install the Skins extension.
  • The new Python extension is now available. It allows customers to deploy and manage WSGI-based Python applications on their websites directly from Plesk.
  • The Plesk Mobile apps for iOS and Android and the Plesk Mobile Center extension have been deprecated, and are no longer available for new installations. In Plesk Obsidian 18.0.84, the Plesk Mobile Center extension will be removed from servers during the upgrade, and the Plesk Mobile apps will lose their server management features.
  • The Social Login extension has been deprecated and will be removed in Plesk Obsidian 18.0.84. After that, it will no longer be possible to log in to Plesk with a Google, Facebook, GitHub account, or with a passkey. Plesk usernames and passwords, as well as logging in with a WebPros Account, are not affected.

Reboot server outside of Plesk control panel?

W

webcanada

Guest
Hey guys,

I'm trying to write a PHP script which I can put in a protected directory, that I can get to using any browser, to reboot the server. I've found that once in a while, things get messed up, or stop running, etc., and a reboot fixes it all.

I would love to be able to initiate a reboot from my phone/PDA (which can't sign into Plesk .. I'm assuming IE Mobile doesn't support JS or something else).

So I've made a script that calls:

$reboot = shell_exec("shutdown -r");

... but this doesn't seem to do anything. The domain on which this script resides has safe mode turned off, but I'm assuming there's some higher level protection that prevents a web user from rebooting the server.

Has anyone done anything similar? Perhaps there's some Plesk API way of doing this?

Thanks!
 
Don't you need s.th. like this?

$reboot = shell_exec("shutdown -r now");

or depending on your distribution perhaps
a
$reboot = shell_exec("reboot");

Good Luck :)
 
Probably it is been disabled in PHP.ini, search for disable_functions

I've got:
disable_functions = curl_exec, exec, ini_alter, parse_ini_file, passthru, shell_exec, pfsockopen, proc_close, proc_get_status, posix_six_setuid, posix_setsid, posix_setpgid, posix_kill, system, proc_nice, proc_open, proc_terminate

So your script will most definitly NOT work on my server...

edit:
Notice that PHP will run your script as apache, and i dont think that apache is allowed to reboot a server either.

Try to learn more working with ssh and restarting the services. Like /etc/init.d/httpd start|stop|restart etc.
If a services fails to start, is maybe because of an existing PID, kill the pid and try again. Or for httpd try /etc/init.d/httpd configtest, before restarting the service

SSH works perfect on a mobile/PDA, and is saver than a browser... (in my humble opinion ;) )
 
Back
Top