Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have 2 webservers and 5 mysql servers. Our website has a lot of traffic and one of the mysql servers goes down or gets flooded and i need to restart it (/etc/init.d/mysql restart).

Can i do it via PHP script (runing ssh command via php or something?)

Thank you

share|improve this question

You can, but its probably not a very good idea. You're better off installing something like nagios, monit, or god to monitor your mysql instance and restart it if it fails.

The biggest problem with exposing a php script like that is that it would need to run with root privileges to run any init script. So while I'm sure you could password protect it and hide it well, its just not a wise choice when there are monitoring tools that can automatically restart a failed service.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.