Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Help to monitor a PID

by Corion (Patriarch)
on Sep 13, 2016 at 10:13 UTC ( [id://1171653]=note: print w/replies, xml ) Need Help??


in reply to Help to monitor a PID

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'`; }

Replies are listed 'Best First'.
Re^2: Help to monitor a PID
by lsvolo (Novice) on Sep 13, 2016 at 10:17 UTC
    Thank you both for you comments and the time spend to assist! Work fine now

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1171653]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (4)
As of 2024-04-19 06:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found