I have a process that has been crashing every few days, but needs to be running 24/7 to be effective. Until I find the time to seek out the cause, I need the process to be restarted.
This short SH script uses PS to check that the process is running, and if not, runs the given init-script to restart the service.
checkprocess.sh [process] [init-script]
checkprocess.sh myprocess /etc/init.d/myprocess
checkprocess.sh writes a log at /var/log/checkprocess.log, and sends an alert mail to root should the process require restarting.
Put the checkprocess.sh command into crontab to check regular for the crashed process. For debian the crontab entry would look similar to:
*/1 * * * * root /usr/local/bin/checkprocess.sh mythbackend /etc/init.d/myth-backend
checkprocess.sh (723 bytes, 1,666 hits)