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
[email protected]
(213)300-9448
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/