Reading: Felicia Day’s autobiography, You’re Never Weird on the Internet (Almost). In fact, I’m listening to it. First crack at using my library’s audio book reservation. It’s a fantastic book; very relatable and touching. A story of an interaction with a fan may have made my bus ride home uncomfortably dusty.
I’ve moved on from
ps aux | grep -i processname; kill PID. The Mac (along with many other Unix-likes) has two handy utilities:
pgrep does a case-insensitive search for processes matching the expression you provide, and returns all matching PIDs, one per line.
pkill does the same search, but just kills the matching processes instead of returning the PIDs.
A common use case for me is
middleman hanging when I change the
config.rb. I could kill it using the following:
kill `pgrep middleman`
One of the benefits of using
pkill is that you can run the command interactively. Handy if you end up searching on the scripting language running the process, rather than something a bit more unique.