Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

killing multiple process

785 views
Skip to first unread message

Weng Lee,Yap

unread,
May 5, 2001, 2:23:38 PM5/5/01
to
Hi,

How can I kill multiple processes at one go?

Regards,
Will

James Martini

unread,
May 5, 2001, 3:27:11 PM5/5/01
to
Weng Lee,Yap wrote:

> How can I kill multiple processes at one go?

If you're running Solaris 7 or 8 the 'pkill' command is pretty handy. On
2.6 I use the following:

kill `ps -ef | grep process-name | grep -v grep | awk {'print $2'}`

James


Logan Shaw

unread,
May 5, 2001, 3:47:16 PM5/5/01
to
In article <3AF4452A...@pacific.net.sg>,

Weng Lee,Yap <will...@pacific.net.sg> wrote:
> How can I kill multiple processes at one go?

Put all their pids on the same command line:

kill -HUP 321 654 987

- Logan
--
my your his her our their _its_
I'm you're he's she's we're they're _it's_

Chris Thompson

unread,
May 5, 2001, 6:43:40 PM5/5/01
to
In article <9d1nh2$41u$1...@moek.pir.net>,
Peter Radcliffe <27$10$f3i...@pir.net> wrote:

>James Martini <jmar...@millenniumgroup.org> probably said:
>>kill `ps -ef | grep process-name | grep -v grep | awk {'print $2'}`
>
>Pet peeve #36. If you're piping grep into awk, you shouldn't be.
>
>ps -ef | awk '/process-name/ {print $2}' | xargs kill

Pet peeve #37. Use the -o option of ps(1) [available since 2.5] and
test the right field for the right contents.

Chris Thompson
Email: cet1 [at] cam.ac.uk

James Martini

unread,
May 6, 2001, 2:04:33 PM5/6/01
to
Peter Radcliffe wrote:

> James Martini <jmar...@millenniumgroup.org> probably said:

> >kill `ps -ef | grep process-name | grep -v grep | awk {'print $2'}`
>

> Pet peeve #36. If you're piping grep into awk, you shouldn't be.
>
> ps -ef | awk '/process-name/ {print $2}' | xargs kill

Pet peeve #1: People who say 'x is better' without justifying their
assertion. But...

Your right, the awk '/process/ {print $2}' construction is a more efficient
and elegant. I used the first to stop a runaway sendmail on a production
system that was bouncing 5 msgs a second after a jr admin removed
/etc/mail/aliases.db (and on the standard means of stopping it were no
effective). I guess the stress burned it into my my brain since I never
considered doing it another way since.

James

Chris Thompson

unread,
May 6, 2001, 6:28:17 PM5/6/01
to
In article <9d2b0v$ar8$1...@moek.pir.net>,
Peter Radcliffe <27$10$f3i...@pir.net> wrote:

>Chris Thompson <cet1-...@cam.ac.uk.invalid> probably said:
>>Pet peeve #37. Use the -o option of ps(1) [available since 2.5] and
>>test the right field for the right contents.
>
>Not very portable.

Well, scripts post-analysing the output of "ps" are hardly "very portable"
at the best of times.

However, robustness within the context of a particular Unix flavour is
worth trying to achieve.

0 new messages