PDA

View Full Version : Script to check mysqld is running?


charlesr
08-09-2012, 06:05 AM
Once in a blue moon, my server goes nuts, and when it recovers, mysqld is down. Is there a script I could run every hour in cron that could check it and start it if need be? Just in case I'm not around when it happens.

Something including this I guess: /etc/rc.d/init.d/mysqld status

If it is running I'd expect to see something like mysqld (pid 5409) is running...

Simon Lloyd
08-09-2012, 10:02 AM
This article and script will do what you want http://www.motionlab.co.uk/blog/monitor-apache-and-mysql-and-restart-automatically-with-php-cli-cron-script/2011/03/

It's a cron script :)

charlesr
08-09-2012, 01:24 PM
Ah cheers. I also found "monit" which I'm trying first, but battling with the set up at the mo.
Thanks.

Simon Lloyd
08-09-2012, 01:55 PM
with the one in that link you just set a server cron job to run the script.