Redirecting Multiple STDOUT and STDERR to One Logfile

For my own future reference. Works in Linux and Mac OS X.

Situation: Run two commands in cron. The first creates a new logfile of its output (both STDOUT and STDERR), but the second appends its output (again, both STDOUT and STDERR) to the same file as the first.

$ command1 2>&1 /path/to/logfile
$ command2 >> /path/to/logfile 2>&1
Advertisements