From owner-freebsd-questions Thu May 8 09:42:38 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id JAA06789 for questions-outgoing; Thu, 8 May 1997 09:42:38 -0700 (PDT) Received: from ds9.abac.com (qmailr@ds9.abac.com [206.171.121.64]) by hub.freebsd.org (8.8.5/8.8.5) with SMTP id JAA06784 for ; Thu, 8 May 1997 09:42:33 -0700 (PDT) Received: (qmail 20851 invoked by uid 501); 8 May 1997 16:42:29 -0000 Date: Thu, 8 May 1997 09:42:29 -0700 (PDT) From: Bryce Newall To: FreeBSD Questions List Subject: Re: Keeping a process running In-Reply-To: <01BC5BA1.7F07A140@dans-zyga-pc.zyga.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-questions@freebsd.org X-Loop: FreeBSD.org Precedence: bulk On Thu, 8 May 1997, Dan Wolfe wrote: > I have a process called 'startslip' in FreeBSD that I want to > periodically check using cron to make sure it is still running, and if > it has stopped, to restart it. Can anyone give ideas on the best way to > accomplish this? I'm assuming you're using pppd or something like that to keep your connection going? I have a script on my system at home that checks to see if my pppd is running, and if it isn't, it executes another script called ppp-on (which just dials out and then runs pppd to handle the connection). Granted, my home system is Linux and not FreeBSD, but it should work pretty much the same. The script is cronned to run every 5 minutes. Here it is: #!/bin/sh PIDFILE="/home/data/ppp.ps" ps -ax > $PIDFILE if [ `grep -c "pppd" $PIDFILE` -eq 0 ]; then /usr/sbin/ppp-on fi rm -f $PIDFILE The reason for having "ps -ax" in there is in case I run ppp-on as root (thereby running pppd as root). If I did that, then a ps -x executed as data wouldn't find pppd, and would try to spawn a second copy. You'll have to tailor this script for you needs, of course... but it should get you started. :) ********************************************************************** * Bryce Newall * IRC: Data * Email: data@dal.net * * WWW: http://voyager.abac.com/data * IRC Admin, voyager.dal.net * * --== Try DALnet! Server irc.dal.net, port 7000 ==-- * * "Stop smirking, Number 1." -- J.L. Picard * * "I'm a doctor, not a doorstop!" -- EMH Program, ST:FC * **********************************************************************