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

What is unix and why it is used?

0 Answers  


What does unix .profile contains?

0 Answers   BPL,


What is the full form unix?

0 Answers  


What do you mean by unix operating system?

0 Answers  


What does tr H do in unix?

0 Answers  






What is the use of grep and egrep in unix?

0 Answers  


Interviewer: Lets say there is a partition of 100GB. When i tried to create a file using touch command, under any directory, it was unable to create the file- '100% full disk space'. I calculated the size of each and every directory on that partition mannually by adding each file size & in came out to be total size 50GB. Then where is the remaining 50GB ? why it is showing disk space 100% full in 'df -h' command?

2 Answers   Infosys,


What is alias mechanism?

0 Answers  


Is mac unix based?

0 Answers  


What are shell variables?

0 Answers  


What does cd mean in unix?

0 Answers  


What is unix mtime?

0 Answers  


Categories