0 Replies - 1145 Views - Last Post: 15 October 2007 - 04:01 AM

#1 no2pencil  Icon User is offline

  • Professor Snuggly Pants
  • member icon

Reputation: 6560
  • View blog
  • Posts: 30,699
  • Joined: 10-May 07

check for process

Posted 15 October 2007 - 04:01 AM

Description: This script will check for a defined process & tell log if it finds that the process is not running. It will also make an attempt to auto start the process. This may need to be changed for services other than httpd. You could also add an option to use sendmail to notify you of the outage.
#!/bin/sh
SERVICE='httpd'

if ps ax | grep -v grep | grep $SERVICE > /dev/null
then
    echo "$SERVICE service running"
else
    echo "$SERVICE is not running" >> /var/log/messages
    # attempt to auto start
    $SERVICE -k start 
fi


Is This A Good Question/Topic? 0
  • +

Page 1 of 1