If you have a MySQL powered website it is critical that the MySQL Server is running. This little diddy will check to see that the MySQL Server is running and restart it if it's not.You will need to add an entry to your crontab that runs on a interval you are comfortable with. This example runs every minute although you can set it to run as often as you like. The command is very low on system resources so one minute is a good place to start.
0-59/1 * * * * ps -ef | grep mysqld | grep -v grep >> /dev/null || /etc/init.d/mysql start
Note: This should all be on one line in your crontab
Just insert this in your crontab on the server that is running the MySQL server (it's a good idea to put it in the crontab for root or a superuser) and the server will do the rest.
J Cornelius is a software developer, Web developer, and Formula 1 fan in Atlanta GA. He has a strange affinity for odd numbers, european sports cars, thoughtful analogies, and is hopelessly addicted to chips & salsa. Read more
Was it good for you?
Post to Digg Post to del.icio.us Post to ma.gnolia Post to Furl Post to Mixx