I share a dev server with some colleagues, it's a Ubuntu server and we have several scripts there, so basically the usual way we run a process is using a screen session. My problem is that when I do ps aux| grep python I see a running process:

root     x  x  x x x x  Ss   Apr12  29:58 /usr/bin/python /home/script.py

this script is not being run on a screen session and it automatically starts when killed so I need to know what service is starting/restarting that process. Any help is appreciated.

  • 1
    Well, PepperoniPizza, you can probably audit all execve events which would give the the PID of the process that keeps spawning it and just follow the trail back to something you can recognize. – Bratchley Apr 24 '14 at 15:21

You can use pstree to get a tree view of the all the process along with their parents. In the following example I will get the parent process of pulseaudio, which have PID of 1913:

$ pstree -sU 1913   

In your case I would use pgrep plus pstree, like this:

pstree -sU $(pgrep /home/script.py)

Notice, that if the script parent was killed is highly likely that its parent will be init. In such case, you will need a more aggressive way to get the parent process.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.