A process is running for 1000 times.How to kill all processes except one i.e kill 999 processes?



A process is running for 1000 times.How to kill all processes except one i.e kill 999 processes?..

Answer / lokesh210

I think it will work.
U can kill all the process except one as below,
set a=`ps -ef|grep -c "XYZ"`
ps -ef|grep "XYZ"|head -`expr $a - 1`|xargs kill -9


To kill all the instances of that process
ps -ef|grep "XYZ"|xargs kill -9

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More Unix General Interview Questions

how do display only hidden files in unix?

15 Answers   Accenture,


List some features of unix.

0 Answers  


1)How to schedule a job,that will periodically execute in second by crontab? 2)I know only second specific time to execute the job. like 10 10 * * * sleep 40&&ps -l>/dev/pts/1 It will execute at 10:10:40 AM but do not know how to execute 15 second,30 second so on at 10:10 am.

3 Answers   Qwest,


What is difference between unix and windows operating system?

0 Answers  


What is af_unix?

0 Answers  






How to print/display the last line of a file in Unix?

0 Answers  


What is hardlink and softlink in unix?

0 Answers  


What is the difference between soft link and hard link in Unix operating system ?

0 Answers   MCN Solutions,


What is the procedure to configure MC/SG Cluster services in HP-UX 11i v3 OS Environment?

0 Answers   IBM,


What is alias mechanism? Explain.

0 Answers  


What is file structure in unix?

0 Answers  


Explain how and when a DNS request is solved when a user tries to surf to the site www.abcdeg.in .Assume the user machine uses a local name server and sits on another network other than www.abcdef.in.

1 Answers  


Categories