How to log cron job outputs
Created on March 31, 2026 Updated on April 20, 2026
linux
This works on Ubuntu.
There are two layers to this problem:
- see meta logs of cron
- see the actual logs of the job
meta logs:
# either: /var/log/syslog
sudo grep 'CRON' /var/log/syslog | tail -10
# or alternatively: journalctl
journalctl -u cron
This will tell you that the scheduled cron job ran. It will not log anything from the command that ran.
Example:
2026-04-20T10:06:01.341918+02:00 mylinux CRON[300139]: (davidkuda) CMD (date >> /home/davidkuda/cron.log)
job logs:
You need to use redirection of STDOUT and STDERR. >> ~/logs/job.log 2>&1
Example:
* * * * * date >> /home/davidkuda/cron.log 2>&1
What is the arcane 2&1?
>>append output to file/home/davidkuda/cron.logfile path2>&1redirect STDERR (file descriptor 2) to file STDOUT (descriptor 1)>redirect2file descriptor 2 for STDERR&1file descriptor 1 for STDOUT
There is a very good explanation of this on StackOverflow.