Linux – How to Kill Multiple Instances of a Running Process

killprocess

Suppose I have a thousand or more instances of any process (for example, vi) running. How do I kill them all in one single shot/one line command/one command?

Best Answer

What's wrong with the good old,

for pid in $(ps -ef | grep "some search" | awk '{print $2}'); do kill -9 $pid; done

There are ways to make that more efficient,

for pid in $(ps -ef | awk '/some search/ {print $2}'); do kill -9 $pid; done

and other variations, but at the basic level, it's always worked for me.

Related Question