pidof

Version: 0.1.4 || Release Date: 2007-02-03 || License: Freeware Developer: Night Productions | App Owner: bitnix

When using the "top" command in Terminal, you get the PID (process id's) of every program (actually called processes). :)

Now, If you want to, for instance, perform a "kill" command on a specific process, it's a bit cumbersome to use the "top" command and then search for the specific process in question.

With pidof, you can just type "pidof Safari" for example, and it will give you its PID number(s) right away. You can even type "pidof Saf", and it will (in most cases) bring you the actual PID number. But beware of using this abbreviated method too frequently, since it might give you the PID of a process with the same letters, for instance, it might give you the PID of the application Safe Place, and if you mistakenly kill that process, you will not be asked in beforehand, if you want to save its current state, it just kills it, so be wary of that.

Try it out.

Suggest screenshot/icon / Suggest new version

2 Opinions

groxx:

Well, obviously there are plenty of ways of finding PIDs and killing running processes (and more quickly than you suggest). If you just want to kill a process whose name you already know, for instance, just killall PROCESS.

If you want to kill a process whose name you don't quite know, know how to spell, or are too lazy to write, use a bash script like:

#!/bin/bash
killall $(ps -Ac | grep "$@")

But then the above script doesn't ignore capitalization, so that's a pain in the ass. So you'd modify the script, and so on. The point is that pidof already does all this, and very elegantly. Furthermore, he GPLed it, so you can modify the source to do anything else that you want it to.

The author has a few other command line tools that are very useful, but that you could give the same argument about. xstat in particular shows a bunch of info on a file that would normally take 3 commands to find out. Also GPL.

Sounds nice... but I prefer:
ps -ax | grep Safari
(note that that's a vertical line, like the one you get with shift+\)

Then just type:
kill [the number of the app, which is on the left] (obviously, without the brackets) to kill the app.
Or: kill -STOP [#] to pause, and kill -CONT [#] to resume.
And check it out. Not only can you kill stuff, you can pause it too.