Service watchdog script - input wanted!

This is a general-purpose monitoring script for any service. It will check if the service is running and restart it if it is not via cron. It can also email you when service restarts occur so you can investigate the cause.

Would love to have your input and suggestions on how to improve it.

Example usage in Crontab: */5 * * * * sh /root/watchdog.sh apache2 (Checks if apache is running every five minutes and restart it if it's down.)

*/5 * * * * sh /root/watchdog.sh mysqld mysql ("Loose" check for mysqld every 5 minutes, second parameter is the name of the service to restart, in case the application and service names differ.)

More examples are available at the top of the shell script.

Download: https://dl.dropbox.com/u/2758854/watchdog.sh

Source: https://dl.dropbox.com/u/2758854/watchdog.sh.txt

Requirements: pgrep service

Comments

Sign In or Register to comment.