Archive for the ‘Ubuntu’ Category

Getting the process ID when pidof doesn’t work

August 21, 2008

I have found that sometimes the pidof command does not work. This seems to be the case when a program is actually a script being interpreted by another program e.g. python. It shows up in the ps list of processes with a pid but pidof fails to return it. In this particular case it is Elisa.

There are other ways to do it involving grep and pipes and other programs but this is just a simple single command replacment for pidof.

ps -o pid –no-heading -C elisa

This may not work on all flavours of linux as they have slightly different ps commands but it works fine on Ubuntu 8.10