Hi,
I am monitoring multiple processes and if one fails, a Perl script restarts
it. I've tested the Perl script and it works just fine when run via
terminal. The problem arises when the script is called via cron. Cron logs
shows that it successfully executed the script but it seems that the script
failed to detect if a process is not running. Here is the script (warning
perl newbie)
---- Perl begins
#!/usr/local/bin/perl
# use strict;
my $status = `zmcontrol status|grep "Stopped"`;
open(MYOUTFILE, ">>zprocmon.log");
print MYOUTFILE scalar(localtime), " - Running monitor and restart if
necessary.\n";
if ($status) {
print $status;
print MYOUTFILE scalar(localtime), " - found stopped process,
restarting.\n";
@args = ("zmcontrol","stop");
system(@args) == 0
or print MYOUTFILE scalar(localtime), " - error running the
program.\n";
@args = ("zmcontrol", "start");
system(@args) == 0
or print MYOUTFILE scalar(localtime), " - error running the
program.\n";
} else {
print MYOUTFILE scalar(localtime), " - process are all running, no need
to restart.\n";
}
---- Perl ends
---- Cron entry
# first try
10,20,30,40,50 * * * * /path/to/perlscript > /dev/null 2>&1
# second try
10,20,30,40,50 * * * * /path/to/perlscript
---- End Cron
Is there something wrong?
Thanks
_________________________________________________
Philippine Linux Users' Group (PLUG) Mailing List
[email protected] (#PLUG @ irc.free.net.ph)
Read the Guidelines: http://linux.org.ph/lists
Searchable Archives: http://archives.free.net.ph