Shell – Kill all processes related to an application

killlinuxprocessshell

I have two processes that are temporarily spawned and I need to kill them. Here are the processes from ps aux

david  38329   0.0  5.0  3916476 104624 s002  S    11:33AM   0:17.43 /Applications/Firefox.a
david  38319   0.0  0.0  2442472   1028 s002  S    11:33AM   0:00.10 Xvfb -br -screen 0 800x
david  38268   0.0  0.2  3012352   4960   ??  S    11:02AM   0:00.24 /System/Library/Framewo
david  38261   0.0  3.4  3913364  70724 s002  S    11:02AM   0:08.51 /Applications/Firefox.a

How would I kill all processes that are either Xvfb or Firefox ?

Update: I was able to use $ sudo killall Xvfb to kill that process, but am still having trouble doing the same with Firefox:

davids-Mac-mini:financials david$ ps aux|grep firefox
david          /Applications/Firefox.app/Contents/MacOS/firefox-bin -foreground
david          /Applications/Firefox.app/Contents/MacOS/firefox-bin -foreground
david          grep firefox
davids-Mac-mini:financials david$ sudo killall firefox
No matching processes were found

Best Answer

If you want to do it by name:

killall firefox

If you want to kill a specific process, e.g. the first Firefox instance:

kill 38329

and if the process doesn't want to go, you can use:

kill -KILL 38261

There should be no way for a program to keep the OS from terminating it RIGHT NOW.

Update: To see a list of all available process names for the killall command, you can use:

ps -axco command | sort | uniq
Related Question