From owner-freebsd-questions Wed Apr 23 15:50:13 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id PAA28532 for questions-outgoing; Wed, 23 Apr 1997 15:50:13 -0700 (PDT) Received: from adam.adonai.net ([205.182.92.2]) by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id PAA28523 for ; Wed, 23 Apr 1997 15:50:06 -0700 (PDT) Received: from pbcustomer ([201.182.92.100]) by adam.adonai.net (8.8.5/8.7.3) with SMTP id RAA27184; Wed, 23 Apr 1997 17:51:57 -0500 (CDT) Message-ID: <335E9246.178D@adonai.net> Date: Wed, 23 Apr 1997 17:50:46 -0500 From: Lee Crites Reply-To: leec@adonai.net Organization: Adonai Enterprises, Inc X-Mailer: Mozilla 3.0Gold (Win95; U) MIME-Version: 1.0 To: Dan Wolfe CC: "'questions@freebsd.org'" , "'dsmith@zyga.com'" Subject: Re: Cron jobs References: <01BC4FF0.6D7EC0A0@dans-zyga-pc.zyga.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-questions@freebsd.org X-Loop: FreeBSD.org Precedence: bulk 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 #