Home

Published

- 1 min read

get output of ps aux grep python

img of get output of ps aux grep python

The solution for this is noted below

get output of ps aux grep python

Solution

   import subprocess
cmd = "ps -ef | grep script.py | awk '{print $1,$2,$3,$4}’”
stdoutdata = subprocess.getoutput(cmd)
print("stdoutdata: " + stdoutdata.split()[0])

Try other methods by searching on the site. That is if this doesn’t work