No we cant. As the process itself creates the pid then there is no
gaurentee that the process is live (eg: it could have been kill -9ed, or
the box hard-booted)... however if there is no pid file (and the process
usually manages one) then you can be sure that the process is *not*
running. As such its usually a good first port of call.

If the pid file DOES exist, pull out the id and grep "ps aux" for it. If
you find it then you can check the status of the process and determine what
state its in. If the process doesnt exist in the ps aux - its dead.

If you dont get a pid file in normal execution (or you dont have access to
it) ... then your gonna have to do it the long winded way (greping out
unique attributes from a ps auxww / sockstat etc).

Good luck

-- 
Dan Hardiker [[EMAIL PROTECTED]]
ADAM Software & Systems Engineer
First Creative Ltd

> I would like to monitor 3 different daemon : postfix, amavisd (a virus
> scanner acting as a content filter for postfix) and spamd
> (SpamAssassin, a spam filtering daemon invoked by procmail acting as an
> SMTP server).
>
> Can we be sure that a daemon is running if the .pid file exist?
>
> Gilles.
>
> -----Original Message-----
> From: Dan Hardiker [mailto:[EMAIL PROTECTED]]
> Sent: jeudi 2 mai 2002 12:13
> To: [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
> Subject: Re: [PHP] Test if a daemon is running...
>
>
> What type of daemon?
>
> eg: To see if my pop3 daemon is running I use sockstat... "sockstat |
> grep 110" and process the output.
> eg: To see if my mail redirect daemon is running I
> check /var/run/red_mail.pid
>
> All depends on what you want to do as to how you do it. You could even
> do it in a multitude of ways and use the resulting matrix to determine.
>
> --
> Dan Hardiker [[EMAIL PROTECTED]]
> ADAM Software & Systems Engineer
> First Creative Ltd
>
>> Hello everybody,
>>
>> I would like to know an easy way to check is a daemon is running.
>>
>> What do you think is the best? Try to read a .pid file from the right
>> directory? Use sockets function to try to connect to the listening
>> port of the daemon? Grep the output of "ps -e" ?
>>
>> Thanks for your help !
>>
>> Gilles.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to