Reputation: 23104
In linux, how to use python to check whether an external non-system program is running? Is there a standard module for this task?
Upvotes: 1
Views: 102
Reputation: 22659
Use psutil, e.g.
import psutil
def check_if_running(name):
for ps in psutil.process_iter():
if ps.name == name:
return True
return False
check_if_running('python')
>>> True
Upvotes: 2