I would like to highlight the stderr output somehow in the logs of cron jobs, yet maintain the order of the output the same as if the script were run interactively.
For example, I would like to prepend "@@@@@" to all stderr output in the log so that it's more distinguishable. However, I'd like to keep it in context so that I know what part of the program(s) the statement is coming from.
The base output would be from a command like
find /fst/home/ -name '*ooo*'
where there are lots of
find: /fst/home/m1rxp01/.mozilla: Permission denied
types of lines and the occassional
/fst/home/m1rxp01/.openoffice/share/dict/ooo.
In my shell in emacs, I've somehow got it configured to display stdout in green and stderr in orange. I'd like to log my cron output in a similar way. I've tried stuff such as
system("(((find /fst/home/ -name '*ooo*') | 3>&1 1>&2 2>&3 ) | sed 's/^/STDERR:/')");
but even that puts the STDOUT out of sync with the STDERR, and the files aren't in alphabetical order (in the base case this is true).
I've tried
find /fst/home/ -name '*ooo*' 2>&1 >> h1.log | sed 's/^/STDERR:/' >> h1.log
as well, but with the same mis-timing in the results.
I've tried running the same commands in a Perl script both before and after "unbuffering" STDOUT and STDERR with no change in results.
I know that this is a fairly deep issue, and have spent a day reading up on how Linux handles this, but am coming up empty. Thank you.
In reply to Prepending a string to STDERR output, and logging STDOUT & STDERR synchronously to a file by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |