From owner-freebsd-questions@FreeBSD.ORG Sun Feb 13 19:13:57 2005 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 62DA816A4D1 for ; Sun, 13 Feb 2005 19:13:57 +0000 (GMT) Received: from viefep18-int.chello.at (viefep18-int.chello.at [213.46.255.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 70A4A43D4C for ; Sun, 13 Feb 2005 19:13:56 +0000 (GMT) (envelope-from gabor.kovesdan@t-hosting.hu) Received: from [80.99.33.169] by viefep18-int.chello.at (InterMail vM.6.01.03.04 201-2131-111-106-20040729) with ESMTP id <20050213191354.OPIN23481.viefep18-int.chello.at@[80.99.33.169]> for ; Sun, 13 Feb 2005 20:13:54 +0100 Message-ID: <420FA6F5.1020609@t-hosting.hu> Date: Sun, 13 Feb 2005 20:13:57 +0100 From: =?ISO-8859-1?Q?K=F6vesd=E1n_G=E1bor?= User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: freebsd-questions@freebsd.org Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Subject: Crontab script X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 13 Feb 2005 19:13:57 -0000 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