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

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

Is it possible to create new a file system in UNIX?

633


Which data structure is used to maintain the file identification?

499


What do you understand by the term wild-card interpretation?

481


Explain kernal and shell?

553


In what way the protection fault handler concludes?

525






How to reverse a string in Unix?

568


What are the phases of swapping a page from the memory?

546


How does unix file system work?

508


How to get the n-th field from a Unix command output?

550


How old is unix?

478


How to find out what processes are running in the background in unix?

553


How do I remove 30 days old files in unix?

492


How do you switch from any user type to a super user type?

572


How do I delete files older than 2 days unix?

492


How to check the date in unix?

535