Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re: How to verify if a daemon is up and running ?

by rob_au (Abbot)
on Dec 03, 2002 at 20:53 UTC ( #217343=note: print w/replies, xml ) Need Help??

in reply to How to verify if a daemon is up and running ?

I would recommend the usage of Proc::ProcessTable which I have reviewed previously on this site here. Using Proc::ProcessTable, your code would look something like this:

use Proc::ProcessTable; my $running = 0; my $proc = Proc::ProcessTable->new; foreach ( @{ $proc->table } ) { if ($_->cmndline =~ /testd/) { ++$running; } } if (!$running) { # do something to reinvoke process }

This code will count the number of testd processes running on the system, returned in $running, which should allow you to determine whether this existing process should continue execution.

The other approach to this problem would be to incorporate a process identification or lock file, as suggested by Ryszard above, which can be monitored external the current execution process.


perl -le 'print+unpack("N",pack("B32","00000000000000000000000111110001"))'

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2022-08-09 20:08 GMT
Find Nodes?
    Voting Booth?

    No recent polls found