Linux – how to tell which python script is being executed

I have a number of scripts and processes that fire them on an Ubuntu server. Using top indicates that python is executing something, but there’s no way of telling which script is being executed with the output from top unless i’m mistaken.

Is there a way to check the path to the script file(s) currently being executed by the python interpreter?

  • what @Fraser said in the reply but also stackoverflow.com/questions/564695/… might help..

    – 

  • Stack Overflow is only for questions about software development or tools exclusive to that use. Distinguishing between python foo and python bar in the output of top is no different from distinguishing between vim foo.txt and vim bar.txt; it’s not specific to software development and so is a better fit for Unix & Linux or Super User.

    – 




You can just pass the -c flag to see command line.

e.g.

top -c

   1 root      20   0  165828  11024   8180 S   0.0   0.0   0:00.20 /sbin/init
   2 root      20   0    2324   1192   1084 S   0.0   0.0   0:00.00 /init
   5 root      20   0    2352     80     68 S   0.0   0.0   0:00.00 plan9 --control-socket 6 --log-level 4 --server-fd 7 --pipe-+ 

Alternatively you can use htop which gives much more information.

Leave a Comment