Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 31 Oct 2007 08:52:20 -0400
From:      Mike Jeays <mike.jeays@rogers.com>
To:        freebsd-questions@freebsd.org
Subject:   Re: Help with Cron pleazzzzzzzzzzzz
Message-ID:  <200710310852.20319.mike.jeays@rogers.com>
In-Reply-To: <2cd0a0da0710310458t49610b34h9b19366c3765fe0@mail.gmail.com>
References:  <2cd0a0da0710310458t49610b34h9b19366c3765fe0@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On October 31, 2007 07:58:21 am VeeJay wrote:
> Hello Gurus=85.
>
>
>
> I am running a status script written in Perl (*status.pl*) and want to ha=
ve
> it *Always Running*.
>
>
>
> How can I check through CRON that "status.pl" is running and if NO, then
> start the script execution again?
>
>
>
> Please help and advise=85
>
>
>
> With a bundle of thanks!

You could write a shell script something like:

#!/bin/bash
ps -ax | grep 'status.pl'
if [ $q -eq 0 ]
then
  status.pl
fi

grep will return zero if it finds a line containing 'status.pl', and 1=20
otherwise.

in crontab, use

* * * * * /full/path/to/script-above

and it will check every minute.

But a better fix would be to find the bug in status.pl that makes it crash!




=2D-=20
Mike Jeays
http://www.jeays.ca



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200710310852.20319.mike.jeays>