Redirect Output of Cron Task to File (both stdout and stderr)

17 Aug 2009

After several failed attempts, I finally figured out how to redirect both stdout and stderr to append to the same file:

do_task >> cron.log 2>&1

One of the previous tries was, do_task &> cron.log but this blew away the log file every time instead of appending.

I always forget how to do this, so I figured I’d blog it both for my future reference or for the reference of anyone else who also always forgets how to do this.

Let's talk

I'm one of the founders of Venmo. If you liked this essay/experiment -- or didn't -- @ me.