[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: PID
On Mon, Jul 02, 2001 at 06:49:59AM +0400, Alexander Yurchenko wrote:
> On Sat, 30 Jun 2001, Bob DeBolt wrote:
>
> > Greetings to all
> >
> > I have attempted to find a way to extract a PID for tcpdump
> > so I can stop and archive the logs every day a 11:59 PM.
> >
> > I want to run this in a shell script. Starting TCPDump and archiving is
> > functioning fine. I simply need to get the PID so I can "kill -9 PID"
> > and finish the process.
>
> ps ax |grep tcpdump |awk '{print $1}' |xargs -n 1 kill -9
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Piping grep(1) to awk(1) is a pet peeve of mine. And the gratuitous
xargs(1)? There is also a decent chance you could get the PID of the
'grep tcpdump' command. How about,
kill `ps axc | awk '/tcpdump/ { print $1 }'`
Where we use a 'c' option for ps(1) so that we don't catch our own
command looking for 'tcpdump'.
--
Crist J. Clark cjclark@alum.mit.edu
- References:
- PID
- From: Bob DeBolt <bob.debolt@3web.net>
- Re: PID
- From: Alexander Yurchenko <grange@rt.mipt.ru>