Last Updated: February 25, 2016
·
870
· tristan_roddis

Viewing the output from a process in Linux

On Linux processes often run without any ready way to see what they are doing (e.g. if they are invoked by a cron job). If the process you are interested in cannot be foregrounded (man fg) you can still see it's output by looking at special filehandles under the /proc/ directory.

To see the standard output of a process, proceed as follows:

Firstly, find the process ID of the task you are interested in:

ps aux | grep partofprocessname

The second column of the output will tell you the process ID, e.g. 1234, and you can use this to command to see its standard output:

sudo tail -f /proc/1234/fd/1

(ctrl+C when done)

You can also see the standard error with /2

As found at http://stackoverflow.com/questions/715751/attach-to-a-processes-output-for-viewing

1 Response
Add your response

sudo tail -f /proc/$(ps aux | grep partofprocessname | grep -v grep | cut -d ' ' -f 3)/fd/1
over 1 year ago ·