Date: Sun, 31 May 2009 22:03:57 +0100 From: Frank Shute <frank@shute.org.uk> To: Steven Schlansker <scs@eecs.berkeley.edu> Cc: Kelly Jones <kelly.terry.jones@gmail.com>, freebsd-questions@freebsd.org, utisoft@gmail.com Subject: Re: Waiting for a process to die Message-ID: <20090531210357.GA60342@melon.esperance-linux.co.uk> In-Reply-To: <4A22DDAD.8070504@eecs.berkeley.edu> References: <26face530905311117te38a4faya92733fbfebd9597@mail.gmail.com> <b79ecaef0905311128v2e1921a8p30c6ead961759780@mail.gmail.com> <4A22DDAD.8070504@eecs.berkeley.edu>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, May 31, 2009 at 12:42:37PM -0700, Steven Schlansker wrote: > > Chris Rees wrote: > >[ `ps ax |grep pid | wc -l ` = 1 ] && (echo "done!" | Mail -s "PROC > >DONE" kelly.terry.jones@gmail.com) > > > > Not always going to work. For example, > > [steven@scs:~]% ps ax | grep init > 1 ? Ss 0:39 init [2] > 13421 pts/1 R+ 0:00 grep init This is why you should use pgrep(1) to find a PID (and kill it) rather than directly grepping a ps output like the previous poster did. > > Also if you use its pid, 1, you get a whole bunch of uninteresting > processes as you're grepping for "1" ;) > > [steven@scs:~]% ps ax | grep 1 | wc -l > 94 > Wojcech nailed the approach the OP should be using. Regards, -- Frank Contact info: http://www.shute.org.uk/misc/contact.html
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20090531210357.GA60342>