Assuming that you need to save both standard and error logs by two processes on a same file.
$ command1 mesg... error... mesg... .... $ command2 mesg... mesg... mesg... error.. ....
How to do that? The following code looks good, but it doesn't work as you want.
$ (command1 >& log.txt) & $ (command2 >& log.txt) &
You can find only the logs of
How about trying this?
$ (command1 2>&1 >> log.txt) & $ (command2 2>&1 >> log.txt) &
It is better, but it doesn't work as you want as well. The result is not chronically ordered because of buffering.
Do the following code:
$ (command1 2>&1 | cat >> log.txt) & $ (command2 2>&1 | cat >> log.txt) &
It's tricky. The part of
| cat >> means not to buffer the outputs.