LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   how to retreive PID of specific python script using pidof (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-retreive-pid-of-specific-python-script-using-pidof-712678/)

Mash 03-18-2009 10:01 PM

how to retreive PID of specific python script using pidof
 
Hello,

Im trying to write a simple script that will only launch a process if it is not already running.

I want to use the return value from 'pidof' to find out whether it is running.

However the process i am looking for is a script launched with python. Thus if I use "pidof python" I get multiple PIDs returned which is no use.

I also thought of using return value from grep <script.py> but this returns the grep process aswell.. argh!

Any ideas?

Mash 03-18-2009 10:28 PM

Nevermind,

if you do a:

ps ax | grep -v grep | grep process

the middle command removes the grep process running from the list. You can then use the return result from this to branch your if statement


All times are GMT -5. The time now is 12:42 AM.