Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: How best to see if syslogd is running?

by BravoTwoZero (Scribe)
on Jan 04, 2005 at 16:28 UTC ( #419288=note: print w/replies, xml ) Need Help??

in reply to How best to see if syslogd is running?

Why not:

$pid = "/var/log/"; unless (stat($pid)) { print "$pid not running\n"; }

Is there a reason why running stat on the pid file is a Bad Idea? I'm not suggesting it's the best way, mind. I'm just wondering if it's acceptable.

Updated: Thanks, bluto. I'd totally let that evacuate my brain. Cat the pid file to get the process id for which to grep in ps. Buh.

So, just to run mine into the ground:

$pid = "/var/run/"; if (stat($pid)) { open(PID, "< $pid"); my $id = <PID>; chomp $id; if($id) { print "$id running\n"; } else { print "$pid not running\n"; } close PID; } else { print "$pid not running\n"; }

... but it's just for my own excercise at this point. The stat is pointless, since I could just as easily bail if it dies on opening the file in the file handle.

Amatuers discuss tactics. Professionals discuss logistics.

And... my cat's breath smells like cat food.

Replies are listed 'Best First'.
Re^2: How best to see if syslogd is running?
by bluto (Curate) on Jan 04, 2005 at 16:51 UTC
    Because the existance of the file does not prove syslogd is currently running since it may have terminated and not cleaned up the pid file (e.g. it crashes for some strange reason or someone sends it a nontrapable signal like SIGKILL).

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2021-01-19 06:06 GMT
Find Nodes?
    Voting Booth?