Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 03-18-2009, 11:01 PM   #1
LQ Newbie
Registered: Dec 2006
Posts: 16

Rep: Reputation: 0
how to retreive PID of specific python script using pidof


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 <> but this returns the grep process aswell.. argh!

Any ideas?
Old 03-18-2009, 11:28 PM   #2
LQ Newbie
Registered: Dec 2006
Posts: 16

Original Poster
Rep: Reputation: 0

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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to pidof a runing script (user) in order to kill it? frenchn00b Programming 12 01-07-2009 08:54 PM
get the pid of a a specific instance of the same program helsing Linux - Newbie 2 03-10-2008 01:10 PM
how to kill specific python script melinda_sayang Linux - General 2 12-04-2005 04:31 AM
How do I get PID info about a specific script? Stepaj47 Linux - Newbie 2 11-14-2005 05:31 PM
how to get PID without using pidof command? ruchika Programming 2 09-22-2003 04:12 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:25 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration