[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Killing a range of PIDS

Posted on 2005-04-25
10
Medium Priority
?
3,497 Views
Last Modified: 2012-08-13
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
0
Comment
Question by:asidu
  • 3
  • 3
  • 2
  • +2
10 Comments
 
LVL 34

Assisted Solution

by:PsiCop
PsiCop earned 200 total points
ID: 13860363
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
 
LVL 4

Accepted Solution

by:
bytta earned 400 total points
ID: 13860966
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
 
LVL 23

Assisted Solution

by:Mysidia
Mysidia earned 400 total points
ID: 13863549
kill `awk 'BEGIN{for(i=980;i<=995;i++){print i}}'`
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 4

Expert Comment

by:bytta
ID: 13865508
I forgot the cmd line:
for i in $(seq 980 1 995); kill $i; done
0
 
LVL 9

Assisted Solution

by:gtkfreak
gtkfreak earned 200 total points
ID: 13869405
You can also use ksysguard which is in the KDE GUI and you can delete all the processes you select.
0
 
LVL 9

Expert Comment

by:gtkfreak
ID: 13869413
Press ALT+F2 key and then type ksysguard in the command and run.
0
 
LVL 12

Author Comment

by:asidu
ID: 13872560
Thank you guys, for the inputs.
Killall with the programe name does the job in my case.

Cheers
Asidu

0
 
LVL 12

Author Comment

by:asidu
ID: 13873231
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
 
LVL 4

Expert Comment

by:bytta
ID: 13874538
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
 
LVL 12

Author Comment

by:asidu
ID: 13883968
Thanks bytta.
Your  for loop  works fine.
Asidu
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have written articles previously comparing SARDU and YUMI.  I also included a couple of lines about Easy2boot (easy2boot.com).  I have now been using, and enjoying easy2boot as my sole multiboot utility for some years and realize that it deserves …
Often times it's very very easy to extend a volume on a Linux instance in AWS, but impossible to shrink it. I wanted to contribute to the experts-exchange community a way of providing a procedure that works on an AWS instance. It can also be used on…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Suggested Courses
Course of the Month19 days, 13 hours left to enroll

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question