Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

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

by rob_au (Abbot)
on Dec 03, 2002 at 20:53 UTC ( [id://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?
Username:
Password:

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

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

    No recent polls found