Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 8 May 1997 09:42:29 -0700 (PDT)
From:      Bryce Newall <data@ds9.abac.com>
To:        FreeBSD Questions List <freebsd-questions@freebsd.org>
Subject:   Re: Keeping a process running
Message-ID:  <Pine.LNX.3.96.970508093634.20608H-100000@ds9.abac.com>
In-Reply-To: <01BC5BA1.7F07A140@dans-zyga-pc.zyga.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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    *
**********************************************************************




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.LNX.3.96.970508093634.20608H-100000>