• Introducing WebPros Cloud - a fully managed infrastructure platform purpose-built to simplify the deployment of WebPros products !  WebPros Cloud enables you to easily deliver WebPros solutions — without the complexity of managing the infrastructure.
    Join the pilot program today!
  • Support for BIND DNS has been removed from Plesk for Windows due to security and maintenance risks.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS.

How do I reboot the server OUTSIDE of Plesk CP?

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!
 
This isnt really what you wanted, so please excuse it, but you can restart some services from plesk API - you may be able to find it does a reboot but its not documented.
<packet version="1.4.2.0">
<server>
<srv_man>
<id>postgresql</id>
<operation>start</operation>
<id>mysql</id>
<operation>start</operation>
</srv_man>
</server>
</packet>

beyond that if you have secured your web server then a lot of times shutdown command is configured to only be allowed from certain users.

Check /etc/inittab file

Code:
ca::ctrlaltdel:/sbin/shutdown -a -t3 -r now

its possible that you need to add the user that the site runs as to the /etc/shutdown.allow file

Also, have you tried putting in the full path?
"/sbin/shutdown -a -t3 -r now"

You should also check the php.ini file to make sure you are not disabling the shell functions and that kind of stuff.

I ran into a problem similar with plesk event handlers, I found that plesk was not able to execute a php file that did what I wanted/needed on an event handler, but if I put
"php -f /path/to/file.php"

into an sh script, and then called that file it seemed to work fine. maybe thats worth a shot :)
 
It doesn't work because your web server user isn't allowed to restart the server - that would be a VERY bad thing :p. If you must make this work, then you need to give the webserver user (usually "www" or "apache") sudo access to the /sbin/shutdown command so he can execute it. Sudo allows you to do things as superuser. You will need to go into the shell and type visudo to edit the sudoers file. Look for a sudo tutorial on Google.
 
Back
Top