I'd like to monitor a running script and if the script stops running, restart 
it and continue to monitor it. I need a little help from the community on the 
ins-and-outs of the details. But, basically I need someone to look at the 
following code/pseudo-code and give suggestions.

1) Check a script running.
2) If it's running, sleep for 30 seconds then check again.
3) If it's not running, restart it and continue to check after that.

This is on a Red Hat box, so the first thing would be something like:

While (1) {
    my $process = `ps -ef | grep <process name> | grep -v grep`;

    if ($process) {
        sleep 30} else {
        exec (./<process name>) or print STDERR "couldn't exec <process name>: 
$!";
    }
}

Ron Smith
geeksatla...@yahoo.com
(213)300-9448


-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to