On Sat, 20 Jan 2001, John H Darrah wrote:
| > > A more robust solution would be:
| > >   ps -ec | awk '$6 ~ /ntpd/ {print; exit}'

rpjday wrote:
| > you know, if what you're trying to do is get the PID of the
| > ntpd process, the *proper* way would be to examine the file
| > /var/run/ntpd.pid, at least under red hat linux.
| >
| > i know that the /var/run directory contains *.pid files for
| > most system services, so i'm assuming it has one for ntpd
| > as well.  then you can stop dicking around, grepping and
| > awking.

On Sat, Jan 20, 2001 at 02:22:28PM -0600, Bret Hughes <[EMAIL PROTECTED]> wrote:
| or how 'bout
| pidof xntpd

Well, internally, pidof is doing the same grep tricks. It's
_inherently_ unreliable. Suppose you have a multiuser system with
people running private daemons for some reason. Or an unfortunate
resemblance between command names. Or whatever.

rpjday's point is correct - the system daemons log their pids in well
known (and configurable) places. Precisely so you can just grab it
instead of playing silly guessing games.

All this grepping and awking is good for learning to do "robust"
searches of listings like ps outputs, and for those occasions where
you're _not_ after the system daemon and have to grub through the ps
(eg to find all the pids of some runaway fork-mad script) but are not
the "right" way to locate pids of well behaved daemons.

_Many_ solaris control scripts play games like this (grubbing through
ps) and I wince in pain whenever I have to see such stuff when chasing
a problem.

Many daemon authors have gone to a little trouble to log pids where they're
easy to get to and unambiguous. Make use of their efforts.

Cheers,
-- 
Cameron Simpson, DoD#743        [EMAIL PROTECTED]    http://www.zip.com.au/~cs/

It's in the rich legal tradition of Apple Computer who, in their famous
suit against Microsoft and HP, claimed that the idea of ripping off
Xerox was their intellectual property.
        - John Iodice <[EMAIL PROTECTED]>



_______________________________________________
Redhat-list mailing list
[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/redhat-list

Reply via email to