duncanlock.net

Switch on logging for cron

Edit the /etc/rsyslog.conf or /etc/rsyslog.d/50-default.conf (on Ubuntu) file and make sure you have the following line un-commented (or add it if it’s missing):

cron.*                         /var/log/cron.log

Then restart rsyslog and cron:

$ sudo service rsyslog restart
$ sudo service cron restart

Cron jobs will now log to /var/log/cron.log. What cron actually outputs to this log looks something like this:

Jan 31 07:30:01 duncan-desktop CRON[3971464]: (duncan) CMD (/home/duncan/bin/backup-chrome-window-placement.sh 2>&1 # JOB_ID 3)
Jan 31 07:31:04 duncan-desktop anacron[3971646]: Anacron 2.3 started on 2021-01-31
Jan 31 07:31:04 duncan-desktop anacron[3971646]: Will run job `cron.daily' in 5 min.
Jan 31 07:31:04 duncan-desktop anacron[3971646]: Jobs will be executed sequentially
Jan 31 07 …
Continue reading “Debugging cron jobs”