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

Don't mess with grepping, or even running ps. Get the pid, and kill 0, $pid; it to see if it's alive. If you must run ps, don't grep, but call it like ps h 1234 where 1234 is the pid wanted, and see if it outputs anything or even its exit status.

Replies are listed 'Best First'.
Re^2: How best to see if syslogd is running?
by Fletch (Bishop) on Jan 03, 2005 at 21:33 UTC

    Not that this isn't a good suggestion, but be careful as ps usage and arguments can vary greatly between OSen (and sometimes even between releases of the same OS :). While the example given works fine on Linux, on all three of OS X, FreeBSD, and OpenBSD it'll still print a header line even when given a single pid (the -h means "print headers every page of output" according to the man page, although it doesn't seem to do anything different that I can tell . . .).

    I won't even get into SysV-esque ps . . .

    Update: Reworded to make more clear that it's the BSD-y ones that insist on a header.