Service Monitoring

Associate
Joined
14 Apr 2008
Posts
1,230
Location
Manchester
Hello,

One of our linux based services occasionally falls over and in these situations i'd like it to auto restart (like windows services do) but as far as i can tell there isn't anything 'built in' to CentOS and the method is via a custom script.

Any suggestions?

Thanks in advance.
 
I'd pop a shell script in cron to run say every 5 mins (or 1 min).

Obviously your milage may vary (your service may be a whole bunch of processes/jvm's etc) - but if its just a process you could do something like the below.

e.g
#!/usr/bin/ksh
MYVAR=`ps -ef | grep "your process string - be specific"`

if [[ $MYVAR = 0 ]]; then
/opt/path/to/your/command -args
fi

Pop this into cron to run on an interval:
E.g 5 Mins
5 * * * * /your/script.sh > /dev/null 2>&1


You could improve something like this by echoing the results of your script with a timestamp into a logfile for you to review.
 
Back
Top Bottom