How can I receive the output of two or more independent processes in a third location without affecting the two processes?
I have two processes, A and B, each running in their own
screen, continuously outputting stuff.
I can run
screen and attach to A to see its output:
12:00 Foo. 12:02 Foo. 12:04 Foo.
Same with B:
12:01 Bar. 12:03 Bar. 12:05 Bar.
And I can combine multiple screens to see both side-by-side or similar.
But I am looking for a way to see the output of these two processes combined into one "stream" of messages:
12:00 Foo. 12:01 Bar. 12:02 Foo. 12:03 Bar. 12:04 Foo. 12:05 Bar.
While also not being able to inadvertently send something like CTRL + C to one of the processes. (I still want to be able to reattach to the processes and interact with them from time to time, which is why I've been using
Thus I don't think I would want to run the two processes together and look at the output directly.
I could use
strace to do something like this:
strace -PIDofA -e write & strace -PIDofB -e write &
But the output is not very pretty:
write(1, "12:00 Foo.", 10) = 10 write(5, "Foo in file.", 12) = 12 write(1, "12:01 Bar.", 10) = 10 write(5, "Bar in file.", 12) = 12 ...
and it doesn't feel like a good solution to run multiple
strace this way to get the combined output.
Perhaps I could make both processes write to a file, and do something like:
tail -f output.txt
But I'm not sure if that will cause problems as the file gets filled with more and more lines of output.
And I'm not sure what happens when two processes attempt to write to the same file at the same time.
So what tool do I use, or how do I redesign my processes so as to display the output of A and B together?
(I'm running this on Debian and accessing it through ssh, if that makes a difference.)