Crontab script

Kövesdán Gábor gabor.kovesdan at t-hosting.hu
Sun Feb 13 19:13:57 GMT 2005


Hi,

I've seen somewhere an easy way to check whether a program with a 
specified pid is running or not. I've made a crontab script to check my 
programs based on this. The script is the following:

#!/bin/sh
PID_FILE="/usr/local/bopm/var/bopm.pid"
PID=`cat $PID_FILE`
EXECUTABLE="/usr/local/bopm/bin/bopm"

if test -r $PID_FILE ; then
       # pidfile exist, is it correct?
       if `kill -CHLD $PID >/dev/null 2>$1` ; then
               # ok, exit silently
               exit 0
       fi
       rm -f $PID_FILE
fi
echo ""
echo "Couldn't find the IRC proxy scanner running, retsarting.."
echo ""
$EXECUTABLE


But unfortunately it starts a new instance of the program even if it is 
running. Somebody suggested that I should remove the `` chars from the 
line that conatins the kill -CHLD command, because `` are to check the 
output, but in this case we are interested in the return value not the 
output. The result was the same.

Could You help me please to fix this script? Or if You know an other way 
for this job, please tell me.

Cheers,

Gábor


More information about the freebsd-questions mailing list