I want an easy way in linux to kill all my current processes.

The problem with kill -9 -1 is that it also kills the current terminal. Is there an easy way to kill everything except the current terminal?

link|improve this question

50% accept rate
1  
Should be on serverfault.com =). – Clement H. Jul 16 '09 at 8:48
2  
why should be in server fault? isn't bash programming too? – flybywire Jul 16 '09 at 8:49
1  
It actually should be on both, but it's not quite possible? – Nathan Fellman Jul 16 '09 at 8:50
this is not about configuring, troubleshooting or administering servers. it belongs here – flybywire Jul 16 '09 at 8:52
It's about bash cli, it belongs either here (server fault) or on superuser. – Cian Jul 16 '09 at 11:36
feedback

migrated from stackoverflow.com Jul 16 '09 at 9:52

This question came from our site for professional and enthusiast programmers.

2 Answers

up vote 1 down vote accepted

This kills all processes except the ones associated with the current terminal:

kill `ps -o pid= -N T`
link|improve this answer
doesn't work under debian. ps lists all processes – ThorstenS Jul 16 '09 at 11:04
The "T" argument to "ps" selects all processes associated with the current terminal and "-N" will negate that. – Inshalla Jul 16 '09 at 16:32
feedback

But just want to say don't use -9 as a knee jerk mechanism as it should be used as a last resort. It can't be caught by the process and doesn't let a process cleanup its resources.

Try maybe kill -15 instead to start.

link|improve this answer
-0.5 belongs to stackoverflow. -0.5 the one who wrote the processes knows best what is good to kill them – flybywire Jul 16 '09 at 8:54
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.