Date: Mon, 12 Dec 2005 10:59:48 -0600 From: Eric Schuele <e.schuele@computer.org> To: Alex Zbyslaw <xfb52@dial.pipex.com> Cc: FreeBSD@keyslapper.net, FreeBSD Questions <freebsd-questions@freebsd.org> Subject: Re: grep'ping the ps output.... Message-ID: <439DAC84.7000601@computer.org> In-Reply-To: <439DA275.70404@dial.pipex.com> References: <439D9FA3.7030603@computer.org> <439DA275.70404@dial.pipex.com>
next in thread | previous in thread | raw e-mail | index | archive | help
Alex Zbyslaw wrote: > Eric Schuele wrote: > >> Hello, >> >> I am sure this is quite trivial, but... >> >> I have need to determine if an app (firefox, or anything really) is >> already running before I perform some action. So I grep the ps >> output. However sometimes (many times) that which I'm searching for >> is present in the output because I am presently grep'ing for it. But >> it is not always there. It seems to be a bit inconsistent. (See below). >> >> I was wondering if someone could explain why it is sometimes there and >> not other times. And how I should correctly go about detecting if the >> process is running before I perform my action. >> > ps | egrep firefox | egrep -v egrep > Thanks guys. Yes... both solutions do fix the problem. Hmm... guess I should've looked before I lept. I assumed the processes were run in order by the shell... however it appears all are started simultaneously as a group. > I can't explain exactly why. It's clearly a timing thing. I guess if > the ps runs quickly enough then perhaps the grep hasn't actually been > started by the shell. > Or if ps iterates over something, then maybe the > grep appears in a part of the list that has already been looked at by ps. > > --Alex > > > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to > "freebsd-questions-unsubscribe@freebsd.org" > -- Regards, Eric
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?439DAC84.7000601>