For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > September 2004 > How do I check to see if a process is running









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author How do I check to see if a process is running
Rob Witzke

2004-09-27, 3:57 pm

If I want to know if a process is currently running such as

user1 1729 1 0 14:58:13 ? 0:00 start

What command do I use to look for it? I know I could do a Unix ps and =
grep for the process name and then awk it down but it seems that there =
has got to be a way in Perl to do this. I been through the Camel and =
Ram books and I can find all sorts of stuff about creating processes but =
I guess I am just missing the part about testing to see if a process is =
running.

Rob Witzke
The Public Library of Cincinnati
rob.witzke@cincinnatilibrary.org

Wiggins d Anconia

2004-09-27, 8:56 pm

> If I want to know if a process is currently running such as
>
> user1 1729 1 0 14:58:13 ? 0:00 start
>
> What command do I use to look for it? I know I could do a Unix ps and

grep for the process name and then awk it down but it seems that there
has got to be a way in Perl to do this. I been through the Camel and
Ram books and I can find all sorts of stuff about creating processes but
I guess I am just missing the part about testing to see if a process is
running.
>
> Rob Witzke
> The Public Library of Cincinnati
> rob.witzke@cincinnatilibrary.org
>


Generally you can't, mostly because systems vary a lot when it comes to
such things as process wrangling, etc. More specifically your best
options are to check the process table, either using Proc::ProcessTable
or with the method you describe, or by having the running process store
a 'pid' file, which is the normal *nix way. Long running services will
generally store the process ID to a file on the system, then other
processes that need to check it or send it signals will read that pid
for the information, if you have control over the subprocess you want to
check you should have it do this.

HTH,

http://danconia.org

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com