Date: Sun, 13 Feb 2005 20:13:57 +0100 From: =?ISO-8859-1?Q?K=F6vesd=E1n_G=E1bor?= <gabor.kovesdan@t-hosting.hu> To: freebsd-questions@freebsd.org Subject: Crontab script Message-ID: <420FA6F5.1020609@t-hosting.hu>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?420FA6F5.1020609>