Getting the process ID when pidof doesn’t work

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

Advertisements

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


%d bloggers like this: