Killing a range of PIDS

Hi Experts,

In linux, I  would lilke to kill a range of PIDS eg 980 to 995.
How can the above be achieved easily and quickly.

I have been killing the pids one at a time when an application
goes cranky. Reckon there should be an easy way to kill a range.

Any pointers would be appreciated.

Thank you.

Asidu
LVL 12
asiduAsked:
Who is Participating?
 
byttaConnect With a Mentor Commented:
killall can kill all instances of a running process, e.g. "killall grep"
fuser can also kill all processes using a certain file/device, e.g. "fuser -k /dev/dsp" to kill all processes using the sound card.

But these can easily kill more processes than you bargained for - so be careful.

kill also accepts many arguments, e.g. "kill 1 2 3 4 5"

0
 
PsiCopConnect With a Mentor Commented:
If the PIDs in question are all children of the application's main process (that's still running), then terminating the parent should also kill the children. Assuming you want to terminate the parent also.
0
 
MysidiaConnect With a Mentor Commented:
kill `awk 'BEGIN{for(i=980;i<=995;i++){print i}}'`
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
byttaCommented:
I forgot the cmd line:
for i in $(seq 980 1 995); kill $i; done
0
 
gtkfreakConnect With a Mentor Commented:
You can also use ksysguard which is in the KDE GUI and you can delete all the processes you select.
0
 
gtkfreakCommented:
Press ALT+F2 key and then type ksysguard in the command and run.
0
 
asiduAuthor Commented:
Thank you guys, for the inputs.
Killall with the programe name does the job in my case.

Cheers
Asidu

0
 
asiduAuthor Commented:
just another clarification the  suggestions

for i in $(seq 980 1 995); kill $i; done

and

kill `awk 'BEGIN{for(i=980;i<=995;i++){print i}}'`

does not work in bash shell.

Am i doing the right thing ?

Asidu

0
 
byttaCommented:
for i in $(seq 980 1 995); kill $i; done # missing "do"
Should be:
for i in $(seq 980 1 995);do kill $i; done

Not sure about awk - it works on my bash (debian), try:
kill $(awk 'BEGIN{for(i=980;i<=995;i++){print i}}')
or the mini version of seq:
kill $(seq 980 995)
0
 
asiduAuthor Commented:
Thanks bytta.
Your  for loop  works fine.
Asidu
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.