I want to make both stderr and stdout go to syslog while stderr also goes to the screen. I'm running a cron job and I've redirected stdout to logger and I leave stderr to go to cron and hence email to me. What I want is for the stderr messages to also go to logger and syslog. That probably made no sense, so here's the example crontab
Quote:
MAILTO=me@example.com
0 0 * * * whizbang | logger -t 'whizbang'
|
As you can see, stdout will go to syslog and stderr will go in an email to
me@example.com
I've figured out that something like :
Quote:
exec 3>&1; whizbang 2>&1 >&3 | tee -a /dev/fd/3 >&2 ; exec 3>&-
|
will work.. sortof. Unfortunately, the stderr winds up all bunched at the end instead of interleaved with the stdout. For example, if whizbang contained:
Quote:
echo "foo"
echo "bar" >&2
echo "baz"
|
I'd get an email saying "bar" and syslog would say "foo" "baz "bar", not "foo" "bar" "baz", which makes it harder to figure out what caused the error.
So, my question is: does anyone know how to produce a stderr on one file descriptor and a combined stderr+stdout on another file descriptor without losing the order of the output?
Thanks!
-Dylan