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

Does windows use unix?

0 Answers  


How to create a blank file in unix?

0 Answers  


How to move a background job to forward?

0 Answers  


In unix, what is echo used for?

0 Answers   BPL,


What is unix full form?

0 Answers  


How do I grep recursively in unix?

0 Answers  


What does ls lrt in unix?

0 Answers  


"ls" command is showing all the subdirectoary and files which are present in the current directoary, i want to cut only directoary name. How to cut only name ?

2 Answers   Cap Gemini,


Which unix shell is best?

0 Answers  


What is grep family in unix?

0 Answers  


Differentiate multiuser from multitask.

0 Answers  


In what way the protection fault handler concludes?

0 Answers  


Categories