Spy on the Output of a Linux Process Using its PID

There may be instances whereby ps -aux has been used to see the PID of a running process and you would like to see its output.

This can be done using:

tail -f /proc/{pid}/fd/1

Remember: replace {pid} with the PID of the process. 1 = stdout, 2 = stderr.

Bonus: to see the command used to execute the process, cat /proc/{pid}/cmdline | tr '\000' ' 'select can be used.

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *