Terminating multiple processes at once with OS X

I really like the activity monitor that goes with os x. But sometime it sucks. For example when you want to kill a group of processes. You can mark multiple entries in the process list but you can not end those.

In my case i had trillions of google chrome helper tasks: (maybe because i keep too many tabs open?! naa, has to be caused be some weired 3rd party plugins 😉

tasklist

The solution is – as it often is – using the command line: “killall”

[mupfel@volkers-imac]$~ > man killall
[mupfel@volkers-imac]$~ > killall -s "Google Chrome Helper"
kill -TERM 37526
kill -TERM 37431
kill -TERM 37133
...
kill -TERM 56046
kill -TERM 631
[mupfel@volkers-imac]$~ > killall -s "Google Chrome Helper"|wc -l
83
[mupfel@volkers-imac]$~ >

The latter command simulates (“-s”) what would be done by “killall”. Using “wc -l” we want to count how many process would be killed. 83 is way to high a number for doing it manually.

Lets see the effect of “killall” without simulation: All google chrome tasks are dead now. And the process list shows only the main chrome process.

Of course you have to be carefull which bunch of processes you terminate. Especially because killall support specifying a regex pattern to match the process to kill  – as always:

with great power comes great responsibilit 🙂

Advertisements

About javavolker71

when i do not write posts on this blog, don't work on or try to break my code i'm spending a reasonable amount of time
This entry was posted in CLI, Linux, OS X and tagged , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s