Tips November 11, 2006 at 7:43 am

Make Your Own pidof Utility

It's often required to know the ID number of a certain process. In many *NIX distributions, this is done using the "pidof" utility which OS X lacks. While we have "killall" which is useful for sending signals to processes by name, what if we just need the ID number? To get it, simply add this line to you ~/.bash_profile file:

pidof () { ps -Ac | egrep -i $@ | awk '{print $1}'; }

Then calling "pidof procname" will give you the PID(s) of the processes whose names contain "procname" (ignoring case). You can also use it to quickly check if a process is running.

No Comments

Leave a reply

You must be logged in to post a comment.