How can I kill multiple processes at one go?
Regards,
Will
> 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
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_
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 <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
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.