grep'ping the ps output....
Sergey Zaharchenko
doublef-ctm at yandex.ru
Tue Dec 13 06:57:41 PST 2005
Hello Eric!
Mon, Dec 12, 2005 at 10:04:51AM -0600 you wrote:
> I was wondering if someone could explain why it is sometimes there and
> not other times.
Sometimes the ps process manages to catch the system state when grep has
not been started yet by the shell. Sometimes it doesn't.
> And how I should correctly go about detecting if the
> process is running before I perform my action.
You may use the -c flag of ps:
-c Change the ``command'' column output to just contain the exe-
cutable name, rather than the full command line.
Like:
df at shark:~> ps axc |grep init
1 ?? ILs 0:00,00 init
--
DoubleF
No virus detected in this message. Ehrm, wait a minute...
/kernel: pid 56921 (antivirus), uid 32000: exited on signal 9
Oh yes, no virus:)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20051213/21d657f4/attachment.bin
More information about the freebsd-questions
mailing list