Kill multiple pid with same process

Sometime back I caught up in a situation where I need to kill multiple pid invoked from same process. So, all process have same name

Assume, process invoked for “vim” editor. If I have 20 “vim” process running and I want to kill all of them, what’s the best way to do it?

#There are multiple ways:

  1. Kill using name:

$killall -9 vim

This is the easy to kill all pid by just giving name.

2. Kill using PID: For this method, we need to write a small bash script to parse all pid by running grep.

So, use $ps | grep “vim”

UID                    PID, PPID, CPU Usage, STime, TTY, CMD, File-Name

 

 

 

This will show all process invoked from vim. Now, we need to filter all PID and then run loop to kill each one by one