I know I can use psutil
to get a list of running processes' names like this
import psutil
for i in psutil.pids():
print(psutil.Process(i).name())
However, If i run a python script with python, psutil only will show me that I have an instance of python running.
So, my question is - if I run a python script:
python script_name
is it possible to detect script_name
by psutil?
Look at psutil.Process(i).cmdline()
docs. Your example would return
['python', 'script_name']