Checking processes without PIDs

jhall at vandaliamo.net jhall at vandaliamo.net
Mon Nov 27 15:26:36 PST 2006


> In the last episode (Nov 27), jhall at vandaliamo.net said:
>> I have written a script to determine if processes are running.  I am
>> using, as an example,
>>
>> ps -ax | grep -c postgrey
>>
>> Ocassionally, I am receiving a notification a process is not running
>> (and it varies which process I receive notifications for).  And, when
>> checking, the process actually is running.
>>
>> Is there a better way to determine if a process is running than using ps
>> and grep?
>
> Reading the program's pidfile and checking to see if that pid still
> exists is the best way.  That only works if your program generates a
> pidfile, though.  Most of the time they're in /var/run or a
> subdirectory.  If it doesn't generate a pidfile, you can try the pgrep
> command, which is better than a "ps|grep" combo because it won't ever
> accidentally match itself.
>

Yes, that works much better for most of the processes I am testing
against!  Two are still giving me problems since their command line has
(perl) listed at the end. Any suggestions on how to better deal with these
two?

They display as follows

  422  ??  Ss     8:04.49 /home/postgrey/postgrey --inet=10023
--greylist-text=Greylisted, see http://www.mnea.org/greylisted.html -d
(perl)

Thanks,



Jay
> --
> 	Dan Nelson
> 	dnelson at allantgroup.com
>




More information about the freebsd-questions mailing list