From owner-freebsd-questions Thu Apr 24 07:02:13 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id HAA07517 for questions-outgoing; Thu, 24 Apr 1997 07:02:13 -0700 (PDT) Received: from md.zyga.com ([204.192.12.2]) by hub.freebsd.org (8.8.5/8.8.5) with SMTP id HAA07509 for ; Thu, 24 Apr 1997 07:02:05 -0700 (PDT) Received: from gold.zyga.com ([204.192.12.107]) by md.zyga.com (8.6.11/8.6.9) with SMTP id JAA11999; Thu, 24 Apr 1997 09:07:14 GMT Received: by gold.zyga.com with Microsoft Mail id <01BC50FB.EB7A3780@gold.zyga.com>; Thu, 24 Apr 1997 22:07:37 -0400 Message-ID: <01BC50FB.EB7A3780@gold.zyga.com> From: Deion Christopher Smith To: Dan Wolfe , "'leec@adonai.net'" Cc: "'questions@freebsd.org'" , "'dsmith@zyga.com'" Subject: RE: Cron jobs Date: Thu, 24 Apr 1997 22:07:36 -0400 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: owner-questions@freebsd.org X-Loop: FreeBSD.org Precedence: bulk Thanks! Dan, I told you it was a 10 liner, I just want to look up old refs. on fine tuning a kron. Deion ---------- From: Lee Crites[SMTP:leec@adonai.net] Sent: Wednesday, April 23, 1997 6:50 PM To: Dan Wolfe Cc: 'questions@freebsd.org'; 'dsmith@zyga.com' Subject: Re: Cron jobs Dan Wolfe wrote: > > FreeBSD Users: > > Has anyone written a script to periodically check if a particular process is running, and if not, restart it? > > -Dan Wolfe > ZYGA Corporation Try this script on for size, it's working for me, anyway... #!/bin/csh -f # # check for program and start it if it is not found # echo "Check/starting process" # # program name should be $1 # if ($1 == "") then echo "usage: $0 program-to-check" exit endif set STR = $1 echo " -- starting "$STR # # see if it is running and start it if needed # if (`ps -aux|grep -v grep|grep -c $STR` == 0) then echo " -- starting process" $STR >>& /dev/null & else echo " -- process already running" endif # # done #