Why can't top find my python processes on ubuntu?

I am running a Kubuntu (ubuntu), and I executed two command-line apps through the terminal. My user is 'martin'. In the 'top' window, i can't see my python3 processes:

python3 command-line-1
python3 command-line-2

Please see the attach file.

enter image description here

2

1 Answer

See if you can get them using

ps -af | grep python3

Otherwise if the python code uses one of the os.exec*() calls, the same process continues but runs the exec'ed command which is the one you will see in top or ps. You can confirm this like this:

  1. Start the command as a background process and recover its pid

    python3 [whatever} & echo Python3 started as PID: $!
  2. Use ps with the PID you obtained:

    ps -p $pid

With some luck you can even catch it "morphing":

#! /bin/bash
python3 {whatever} & pid=$!
for i in {1..10}
do ps -p $pid || exit 1 sleep .2 # adjust for speed
done

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like