Operating System - Linux
1753379 Members
5629 Online
108792 Solutions
New Discussion юеВ

Re: format to kill a range of processes

 
SOLVED
Go to solution
Kyle D. Harris
Regular Advisor

format to kill a range of processes

Hello, I'm looking for the command or format to kill a range of processes. I have a bunch of hanging scripts. Lets say hundreds that didn't run correctly and they are just hanging. How would i kill a range of them.

kill -9 (100-999)

above is assuming i want to kill processes 100 through 999. how would i do that? Thanks in advance.

Kyle
4 REPLIES 4
Caesar_3
Esteemed Contributor
Solution

Re: format to kill a range of processes

Hello!

You can write your own kill (script)
perl:


$signal = shift;
$from = shift;
$to = shift;

for (i = $from; i <= $to; i++)
{
kill ($signal, $i);
}

Caesar
Steven E. Protter
Exalted Contributor

Re: format to kill a range of processes

See this thread:

http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x836cc1c4ceddd61190050090279cd0f9,00.html

See my post entitled gkill

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
Balaji N
Honored Contributor

Re: format to kill a range of processes

echo 2 20 | awk '{ for (i=$1;i<$2;i++) {system(kill i}}'


here the 2 20 are the start and end range for the kill script.

-balaji
Its Always Important To Know, What People Think Of You. Then, Of Course, You Surprise Them By Giving More.
Stuart Browne
Honored Contributor

Re: format to kill a range of processes

Assuming they are all of the same 'name', all spawning it's self over and over, you might give Linux' 'killall' a try.

Unlike the killall of a number of other Unicies, it has the ability to killall of a given process 'name'.
One long-haired git at your service...