Answer the question
In order to leave comments, you need to log in
How to check if a process with that name is running in python3 (on linux)?
How to check if a process with that name is running in python3 (on linux)?
Answer the question
In order to leave comments, you need to log in
for example like this:
import psutil
PROCNAME = "httpd"
for proc in psutil.process_iter():
if proc.name() == PROCNAME:
print proc
pip install psutil
)
Just like ps does - scan the contents of the "directory" /proc/
. All subdirectories of numbers are process ids. Inside the "file" comm
the name of the command is stored, and the symlink exe
points to the real binary from which this process was launched.
Although, if you can install additional packages, then of course it's easier to install psuitl
and not suffer.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question