I have a python script. This python script will attempt to execute Unix command via the system() command. I want to know what this command is.

This logic is hidden very deep inside many dependencies, and I don't want to trace them.

Is there a Unix way to just trace what that process is?

What I've tried:

./parsetoo.py &1&2 > /dev/null & ps aawwxx

I attempted to capture it this way, but I'm not catching the command of interest. I assume ps is being run either before its run or after the program exits. It exits quickly.

Thank you.

  • Thank you, I didn't know about that command. By the time I have my PID-of_script, my script has already run and exited. I ended up using strace and filtering for "execve" calls, which seemed to have worked.
    – Raven
    Jun 15, 2021 at 19:16
  • I have read the text twice now, and have no idea how, but remember I thought you wanted the PID lol. Anyway. Yes, it has it's use.
    – ibuprofen
    Jun 15, 2021 at 21:06

1 Answer 1


I just figured out I can use strace

strace -f -e trace=execve ./pythonscript.py

Super neat stuff, just learned by playing with that command.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .