– Check process & restart

Posted on .

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.

Syntax: [process] [init-script]

Example: myprocess /etc/init.d/myprocess writes a log at /var/log/checkprocess.log, and sends an alert mail to root should the process require restarting.

Put the command into crontab to check regular for the crashed process. For debian the crontab entry would look similar to:
*/1 * * * * root /usr/local/bin/ mythbackend /etc/init.d/myth-backend

Download (723 bytes, 2,128 hits)

Leave a Reply

You may leave the Name and Email fields blank to post anonymously.