Re: Help with Cron pleazzzzzzzzzzzz

2007-10-31 Thread Bill Moran
In response to VeeJay [EMAIL PROTECTED]:

 Hello Gurus….
 
 
 
 I am running a status script written in Perl (*status.pl*) and want to have
 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…

Have you considered something like daemontools?  It's designed for such
a task, as opposed to reinventing the wheel.

-- 
Bill Moran
http://www.potentialtech.com
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Help with Cron pleazzzzzzzzzzzz

2007-10-31 Thread Mike Jeays
On October 31, 2007 07:58:21 am VeeJay wrote:
 Hello Gurus….



 I am running a status script written in Perl (*status.pl*) and want to have
 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…



 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 
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!




-- 
Mike Jeays
http://www.jeays.ca
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Help with Cron pleazzzzzzzzzzzz

2007-10-31 Thread John Nielsen

Quoting Mike Jeays [EMAIL PROTECTED]:

On October 31, 2007 07:58:21 am VeeJay wrote:

I am running a status script written in Perl (*status.pl*) and want to have
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...


You could write a shell script something like:


A couple nits:


#!/bin/bash


#!/bin/sh


ps -ax | grep 'status.pl'


This should probably be something like ps -ax | grep 'status.pl' | 
grep -v grep so you don't get false positives from the grep process 
itself.


JN


if [ $q -eq 0 ]
then
 status.pl
fi

grep will return zero if it finds a line containing 'status.pl', and 1
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!




--
Mike Jeays
http://www.jeays.ca
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]





___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Help with Cron pleazzzzzzzzzzzz

2007-10-31 Thread Andy Harrison
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1



On 10/31/07, VeeJay  wrote:
 I am running a status script written in Perl (*status.pl*) and want to have
 it *Always Running*.



 How can I check through CRON that status.pl is running and if NO, then
 start the script execution again?


Run monit.

http://www.freshports.org/sysutils/monit/

Here's an example config for making sure sshd is running:

$ cat /etc/monit.d/sshd
check process sshd with pidfile /var/run/sshd.pid
  start program  /etc/init.d/sshd start
  stop program  /etc/init.d/sshd stop
  if failed port 22 protocol ssh then restart
  if 5 restarts within 5 cycles then timeout

- --
Andy Harrison
public key: 0x67518262
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.5 (GNU/Linux)
Comment: http://firegpg.tuxfamily.org

iD8DBQFHKHeKNTm8fWdRgmIRAoZGAJ0ZJCzDedOEzVqJFYlniZshPKJmPwCaA8Uh
pPYRFCDdrIk1YgYPcyH0hew=
=dr1X
-END PGP SIGNATURE-
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Help with Cron pleazzzzzzzzzzzz

2007-10-31 Thread RW
On Wed, 31 Oct 2007 10:02:53 -0400
John Nielsen [EMAIL PROTECTED] wrote:


 This should probably be something like ps -ax | grep 'status.pl' | 
 grep -v grep so you don't get false positives from the grep process 
 itself.
 

or simply use: pgrep status\.pl
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]