I have a script that outputs a lot of debug data that I would like to avoid to save on disk (specially since the file system is on a flash memory card). So I run it on the background with nohup
+ &
disposing stdout
and stderr
to /dev/null
.
But when it begins to fail I would like be able to get that debug output on its stdout live. In the manner as when one connects through a serial port of a device to get its output. A stream that can be monitored but it's not stored on the device.
I was thinking in redirect the output to a local UDP socket so I could connect and disconnect from the "stream" without affecting in anyway the script and the very same script wouldn't bother if there's someone listening to the data. But I'm interested in the different techniques I could use, and the tools that are already available.
How can I stream the output of a running process?
Restriction
I can't modify the library that outputs the debug information to stdout
. I have to pipe the script's stdout
to a program that can stream it (not saving to disk the whole output).