Page 1 of 1

How to get Process ID of a python script?

Posted: Thu 05 Jul 2018, 20:04
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

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

Posted: Thu 05 Jul 2018, 20:37
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

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

Posted: Thu 05 Jul 2018, 22:15
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