Tell me more ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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
share|improve this question

migrated from stackoverflow.com May 18 '12 at 23:46

2 Answers

You could do

kill `pgrep Xvfb` `pgrep Firefox`

You can add -f to search the entire command, in case it doesn't find it without the -f.

pgrep -f Firefox 

There is also pkill which takes the same input as pgrep

pkill Xvfb; pkill -f Firefox;
share|improve this answer
I don't have pkill or pkill on my machine. How would I do the same with killall ? – David542 May 18 '12 at 20:58
up vote 0 down vote accepted

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

share|improve this answer
$ sudo killall Firefox No matching processes were found – David542 May 18 '12 at 20:53
Corrected to killall firefox, the process that is actually running is the firefox binary inside the Firefox.app bundle. – Orangenhain May 18 '12 at 20:56
Please see update in question. – David542 May 18 '12 at 20:58
1  
killall firefox-bin should work for you. At least Firefox 13 uses firefox as process name. – Orangenhain May 18 '12 at 21:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.