The following is (one way of ) how to automaticaly check for and restart a dead process running in a linux host
Part A
/bin/netstat -ln | /bin/grep ":80 " | /usr/bin/wc -l | /bin/awk '{if ($1 == 0) system("/sbin/service httpd restart") }'
This checks if there is any service running on port 80, if not it runs the command to start the service (apache httpd in this example)
Part B
Create a cron job to periodicaly do the above
*/10 * * * * /usr/sesame/bash/service_monitor.sh> /dev/null 2>&1
NB: please note the trailing space after the port number
Tested in Redhat|Fedora|CentOS
No comments:
Post a Comment
Feel free to leave a comment