Wednesday, July 04, 2007

Shell Script - Restart Process if not found running

A script to Check if process is running and if not running
then start the process.

You can run this as a cron job in a 5/10 mins interval :

cat chk_if_process_running.sh
_______________________
# check daemon
ps -ef | grep -v grep | grep daemon
# if not found - equals to 1, start it
if [ $? -eq 1 ]
then
/sbin/init.d/daemon start
else
echo "eq 0 - daemon found - do nothing"
fi
________________________