Reputation: 1515
This is a cron job, and the output to STDERR results in an email notification of an error, which I need. However, the errors may be non-fatal, so I also need the STDERR output included in the log with STDOUT. How?
Upvotes: 1
Views: 296
Reputation: 651
The following command works with less characters:
((./your-script 3>&1 1>&2 2>&3- | tee /dev/fd/2) 3>&1 1>&2 2>&3- ) | cat > logfile
Upvotes: 0
Reputation: 22261
OK, I spent a few minutes working out how to do this with just the standard shell command line.
Prepare yourself for a ridiculous command line.
((./your-script 3>&1 1>&2 2>&3 3>&- | tee /dev/fd/2) 3>&1 1>&2 2>&3 3>&- ) |
cat >logfile
The only thing I can say about that abomination is that it works... and I can't find anything simpler that also works. Oh, and, it doesn't require bash
or anything. It works in standard bourne shell.
I haven't got a clue why there has to be | cat
near the end, but it doesn't work without it.
Upvotes: 1