Troubleshoot and Check Cron Job Logs
cron
is very useful tool and mechanism to schedule jobs in Linux operating system. cron
can run scripts, commands, binaries if set properly. But in some cases there may be some mis-configuration or unexpected behavior. So we may not be sure whether cron runs like we want. We can check cron log in order to get more detail about job. By the way more details about cron
can be learned from following tutorials.
Linux Crontab Syntax and Examples
Linux Crontab Tutorial with Examples To Schedule Jobs
Cron Log Path
cron
logs are stored in a general log file named syslog
. This file can be found most of the popular distributions like CentOS, RHEL, Debian, Ubuntu. syslog
file is located regular log directory /var/log/syslog
.
1 |
$ cat /var/log/syslog |

Check Cron Log Lines
As we can see in previous example there are a lot of log lines which is produced by different Linux component. But we need to find cron logs. There is a to filter and check only cron log lines. Every cron log line contains string CRON
. So we will filter lines containing CRON
with grep
command like below.
1 |
$ grep CRON /var/log/syslog |

As we can see log lines provides following information.
Date
provides when the log is createdhostname
provides the hostname of the systemroot
the user account which is used to run cron jobCMD
what type of thing is try to run which is command in this case- and the last part provides the command tried to run
Follow Cron Logs In Real Time
If we want to read the cron job logs in real time we can use tail
command with -f
option. This will read the log file and print to the screen. But before printing we will filter only CRON
lines with grep
command like below.
1 |
$ tail -f /var/log/syslog | grep CRON |