Operating System - HP-UX
1833054 Members
2606 Online
110049 Solutions
New Discussion

Killing multiple processes

 
SOLVED
Go to solution
Kyle D. Harris
Regular Advisor

Killing multiple processes

I have a script that loops which sends out constant processes called "filesystem alert" which is the name of my script. How do i go about killing all processes running that are named filesystem alert? This is pretty urgent, thanks to anybody that can help!!!

Kyle
5 REPLIES 5
Steven E. Protter
Exalted Contributor

Re: Killing multiple processes

The attached script might help. It is quite powerful, use it wisely.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Paul Sperry
Honored Contributor

Re: Killing multiple processes

ps -ef | grep filesystem| awk '{print $2}' > pids

then vi the file pids to put kill -9
(or whatever) at the begining of every line

:%s/^/kill -9 /

make it exacutable

chmod 775 pids

then run it

./pids

Then don't run that script again :)
Jeff Schussele
Honored Contributor
Solution

Re: Killing multiple processes

Hi Kyle,

The safest, but not easiest or fastest way, is to determine all the PIDS by

ps -ef | grep -i "filesystem alert"

Then

kill PID(s)

So let's say that PIDs 1065 6544 8732 1208 are all "filesystem alert" PIDs.

kill 1065 6544 8732 1208

I don't like to do "mass" kills via a script or one-liner unless I'm 100% sure the PIDs will all & always be correct. You kill the wrong PID & you can really mess up a system.

Rgds,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
James R. Ferguson
Acclaimed Contributor

Re: Killing multiple processes

Hi Kyle:

SWIth rgard to the 'kill' avoid using a 'kill -9' if at all possible! Use it only as a last resort. 'kil -9' cang't be caught and thus gives a process no chance to cleanup files and remove shared memory segments.

Start with a simple 'kill'. If that doesn't work, try again with 'kill -hup'. As a last resort (only) issue 'kill -9'.

Regards!

...JRF...
Caesar_3
Esteemed Contributor

Re: Killing multiple processes

Hello!

Try this:
ps -ef | grep "filesystem alert" | awk '{print $2}' | xargs kill

Caesar