How to see the current running Linux processes output^

Issue

I have several Linux (Ubuntu 10.04) processes running on my computer. If I start one of them, I can see the verbose of it on my terminal. I have an other process that start a dozen of those processes so that they run in background. However, I would like to watch the output of one of these processes to see if the output is still ok and there are no error message. I know I could send everything into a log message, however, this would just use too much disk space. So, is there a way to “catch” the output of a running process in Linux using it’s process Id?

Solution

Use redirection like

yourprogram arg1 arg2 > yourprog.out

or probably even (to redirect both stderr & stdout and run in the background)

yourprogram arg1 arg2 > yourprog.out 2>&1 &

In a different terminal, do

tail -f yourprog.out 

With the -f option, the tail command will notice when the file is growing and will display its newest lines

But I can’t see portable way to redirect after. Maybe screen, batch, at, cron might help you. Or opening the /proc/1234/fd/1

BTW, I am surprised you don’t have enough temporary disk space for your output…

And I do like running M-x shell under emacs, and running my programm there.

Answered By – Basile Starynkevitch

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published