See the STDOUT redirect of a running process

Check out the file descriptor #1 (STDOUT) in /proc/$PID/fd/. The kernel represents this file as symbolic link to a file the descriptor is redirected to.

$ readlink -f /proc/20361/fd/1
/tmp/file

A useful tool to see what files are opened by what processes is lsof. You can point it at a specific process with lsof -p1234, and you'll see mostly the same information as you can get with ls -l /proc/1234/fd under Linux, i.e. what files are opened.

The most useful thing with lsof is going the other way round: lsof /path/to/file tells you what processes are using that file.


A lot of answers mention doing it this way:

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

However, I've found that it doesn't always work. Alternatively, the cat sometimes yields results.

cat /proc/{PID}/fd/1

where {PID} can be looked up using the ps aux command.

Also good to mention, is that the number on the end of the command (in this case fd/1) can be changed for other outputs.

 /proc/{PID}/fd/0 # STDIN
 /proc/{PID}/fd/1 # STDOUT
 /proc/{PID}/fd/2 # STDERR