Redirecting Cron Output to a Log File
Add >> /path/log 2>&1 to any cron job to save both normal output and errors to a file. Without this, cron emails the output (or silently drops it), and you have nothing to debug. Use >> to append across runs.
Append output and errors
0 * * * * /opt/app/job.sh >> /var/log/job.log 2>&1
>> appends (keeps history), 2>&1 sends stderr to the same place as stdout so errors are captured too.
Overwrite each run
Use a single > to keep only the latest run: > /var/log/job.log 2>&1.
Log errors only
To save just errors: 0 * * * * /opt/app/job.sh 2>> /var/log/job.err. Discard everything with > /dev/null 2>&1 when you truly don't need output.
FAQ
How do I log cron job output to a file?
Append >> /var/log/job.log 2>&1 to the command. This saves stdout and stderr to the file so you can debug.
What does 2>&1 mean in a cron job?
It redirects stderr (file descriptor 2) to wherever stdout (1) is going, so error messages land in the same log as normal output.
Append or overwrite the cron log?
Use >> to append and keep a history across runs; use a single > to overwrite and keep only the latest run's output.