Once STDERR is redirected, for example to a file, how can it be redirected back to the original file descriptor 2?
#!/bin/sh exec 2>/tmp/err print -u2 'log errors to file' exec 2>&2 (how do we do this???) print -u2 'log errors to console'
This redirection solution should work in a cron job. For example, if cron executes an external script, that script will redirect stdout and stderr to relevant log and error files, respectively. However, if an execution in the script fails or something needs to be reported to the job owner, I need to output the error messages so cron will receive them and send mail.