As for your second question: After your sleep, you only update $pid after printing the message. Maybe consider always updating $pid directly after the sleep instead of updating it after printing in two parts of your program:
$pid = `pgrep -f '[a]bc'`; ... until ($i > 60) { if ($pid) { $timestamp = localtime(time); print $fh ("$pid , $timestamp , $msg\n"); }else{ $timestamp = localtime(time); print $fh ("No pid , $timestamp\n"); } $i = $i +1; sleep 10; $pid = `pgrep -f '[a]bc'`; }
In reply to Re: Help to monitor a PID
by Corion
in thread Help to monitor a PID
by lsvolo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |