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

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Why not:

$pid = "/var/log/syslog.pid"; 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/syslogd.pid"; 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.

In reply to Re: How best to see if syslogd is running? by BravoTwoZero
in thread How best to see if syslogd is running? by Plankton

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (7)
As of 2024-04-23 13:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found