Log Cron Output to a File with tee
Redirecting with >> writes cron output to a log file. If you also want the output visible elsewhere (like docker logs or a monitoring pipe), use tee to send it to two places at once.
Append to a log
The usual pattern appends both stdout and stderr:
*/5 * * * * /path/job.sh >> /var/log/job.log 2>&1
>> appends (keeps history); a single > overwrites the file every run.
Write to a file and stdout with tee
To keep a log file and forward output (e.g. to docker logs via /proc/1/fd/1):
*/5 * * * * /path/job.sh 2>&1 | tee -a /var/log/job.log
tee -a appends; drop -a to overwrite. The 2>&1 before the pipe merges stderr so errors are logged too.
Rotate the log
An always-appending log grows forever. Add a logrotate rule for /var/log/job.log so it's trimmed automatically.
FAQ
How do I log cron output to a file?
Append with >> and merge stderr: */5 * * * * /path/job.sh >> /var/log/job.log 2>&1. Use >> to keep history; a single > overwrites each run.
How do I send cron output to a file and stdout at once?
Pipe through tee: /path/job.sh 2>&1 | tee -a /var/log/job.log. tee -a appends to the file while also passing output through.
How do I stop a cron log from growing forever?
Add a logrotate rule for the log file so it is rotated and trimmed automatically instead of appending indefinitely.