How to get Process ID of a python script?

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
ITSMERSH

How to get Process ID of a python script?

#1 Post by ITSMERSH »

Hi.

Does anyone know how to find out the process ID of a python script?

I need to check if jack_mixer is running, so I need something that returns the process ID of jack_mixer, which is a python script.

Thanks in advance,

RSH

User avatar
fredx181
Posts: 4448
Joined: Wed 11 Dec 2013, 12:37
Location: holland

Re: How to get Process ID of a python script?

#2 Post by fredx181 »

ITSMERSH wrote:Hi.

Does anyone know how to find out the process ID of a python script?

I need to check if jack_mixer is running, so I need something that returns the process ID of jack_mixer, which is a python script.

Thanks in advance,

RSH
Can't test, but I'd say this could do:

Code: Select all

pidjack_mixer=$(ps -eo pid,cmd | grep -v grep | grep "jack_mixer" | awk '{ print $1 }')
echo $pidjack_mixer
Fred

ITSMERSH

Re: How to get Process ID of a python script?

#3 Post by ITSMERSH »

fredx181 wrote:
ITSMERSH wrote:Hi.

Does anyone know how to find out the process ID of a python script?

I need to check if jack_mixer is running, so I need something that returns the process ID of jack_mixer, which is a python script.

Thanks in advance,

RSH
Can't test, but I'd say this could do:

Code: Select all

pidjack_mixer=$(ps -eo pid,cmd | grep -v grep | grep "jack_mixer" | awk '{ print $1 }')
echo $pidjack_mixer
Fred
This seems to work very well.

Thanks! :D

Post Reply