LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   To kill all processes except mine (https://www.linuxquestions.org/questions/linux-general-1/to-kill-all-processes-except-mine-767215/)

balakrishnay 11-05-2009 11:30 PM

To kill all processes except mine
 
Hi All,

I know its repeated question but still i am not clear properly.

I wanted to kill all process of one user except mine ( i.e logged in user to kill all processes).

Normally i used to use this command to kill all processes

kill -9 -1

But this kills all process including my session.I dont want to do this .

2. How to find out all parent process and child process specific to each parent.

Regards

krishna

voyciz 11-05-2009 11:53 PM

You could do something like this:

for process in $(ps -u USERNAME -o pid)
do
kill -9 $process
done

luck.anshu 11-06-2009 10:27 AM

Quote:

Originally Posted by voyciz (Post 3746610)
You could do something like this:

for process in $(ps -u USERNAME -o pid)
do
kill -9 $process
done

The following command will kill all the process ids except your user and root user:
ps au | grep -v "`whoami`\|root\|PID" | awk '{print $2}'| xargs sudo kill -9


All times are GMT -5. The time now is 09:56 PM.