What is the most effect way to monitor a process on a UNIX server and
then have them restart if they fail. Currently, I am doing the following
and would like to know if their is a better way. What I looking for is a
better way to detect a process and identify if it is running or not.
Thanks
 
$go=1;
while ($go == 1) { 
 
$cmd = "ps -auxww |egrep \'(process)\' | grep -v grep 2>&1 |";
 
open (ps, $cmd);
 
while (<ps>) {
 

$cmdA = "ps -auxww | prcoess | grep -v grep | wc -l 2>&1 |";
open (PS1,$cmdA);
$openInstance = <PS1>;
if ($openInstance > 1) {
print "An instance of prcoess is running!\n";
# Initiate Log File, overwrite if its old, append if it was created
today
#
-----------------------------------------------------------------------
    open(LOG,">> $LogFile") || die "can not open file";
    
 
    chop ($wtime = `date +%H%M`);         # get current time stamp
 print LOG "-----------------------------------------------\n";
 print LOG "process is active at $yymmdd at $wtime\n";
 print LOG "-----------------------------------------------\n";
 
close(LOG);
}
else {
system("sh process.sh &");
close;
 
sleep 120;
_______________________________________________
Perl-Unix-Users mailing list. To unsubscribe go to 
http://listserv.ActiveState.com/mailman/subscribe/perl-unix-users


Reply via email to