$ command 2>&1 | tee err.out
To redirect stdout and stderr to different files, and have the stderr goes to the screen as well:
$ command 2>&1 > std.out | tee err.out
To redirect stdout and stderr to the same file while having the stderr displayed on the screen, too:
$ command 2>&1 > all.out | tee -a all.out
The last trick is particularly handy when it comes to writing a cron job. The crontab will only send out email when there is stderr outputs while writing the output to the same file as the stdout.
No comments:
Post a Comment