How to view and read cron logs on Ubuntu, Debian and CentOS?

Better Stack Team
Updated on May 4, 2022

Cron can generate logs, which are very useful in troubleshooting your cron jobs. In this quick tutorial, we will take a look at cron logs – how to find them and how to read them.

Where are cron logs stored?

By default, all cron logs are stored in the main system log which is located in /var/log/syslog on Ubuntu and Debian systems and in /var/log/cron on CentOS.

You can filter cron logs in the system log by running the grep command.

cat /var/log/syslog | grep cron

This applies to Ubuntu and Debian. On CentOS, simply replace the system log directory to /var/log/cron and you are good to go.

How to set up cron.log file?

Another way you can monitor cron logs is to set up separate log file especially for cron logs.

To do this, open the /etc/rsyslog.d/50-default.conf configuration file in the nano editor using the following command:

sudo nano /etc/rsyslog.d/50-default.conf

This will open the configuration file for editing. In this file, uncomment the highlighted line to enable logging cron logs into the /var/log/cron.log file.

#  Default rules for rsyslog.
#  For more information see rsyslog.conf(5) and /etc/rsyslog.conf

# First some standard log files.  Log by facility.
auth,authpriv.*                 /var/log/auth.log
*.*;auth,authpriv.none          -/var/log/syslog
#cron.*                         /var/log/cron.log
#daemon.*                       -/var/log/daemon.log
kern.*                          -/var/log/kern.log
#lpr.*                          -/var/log/lpr.log
mail.*                          -/var/log/mail.log
#user.*                         -/var/log/user.log

# Logging for the mail system.  Split it up so that
# it is easy to write scripts to parse these files.
#                      -/var/log/
#mail.warn                      -/var/log/mail.warn
mail.err                        /var/log/mail.err

# Some "catch-all" log files.


The highlighted line should look like this:

cron.*                         /var/log/cron.log

We are not done yet. Now we need to create the /var/log/cron.log file. To do this, simply run the following command:

sudo nano /var/log/cron.log

Save the empty file and exit. Then restart the rsyslog service:

sudo systemctl restart rsyslog

At this point, all cron logs are stored in the /var/log/cron.log file.

How to watch cron logs in real-time?

To view cron logs in real-time, create watchcron file using the following command:

sudo nano watchcron

Add the following line in the file. Then save and exit the file.

watch -n 10 tail -n 15 /var/log/cron.log

This will refresh the logs event page after 10 seconds and displays the last 15 events on the page.

Add the executable permission to the newly created watchcron file:

sudo chmod +x watchcron

And finally, copy this file in /usr/sbin location using the following command:

sudo cp watchcron /usr/sbin

Now to watch cron log in real-time, simply type watchcron in the terminal and hit enter.

Got an article suggestion? Let us know
Explore more
Licensed under CC-BY-NC-SA

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

We are hiring.

Software is our way of making the world a tiny bit better. We build tools for the makers of tomorrow.

Explore all positions →

Reliability is the
ultimate feature

Delightful observability tools that turn your logs & monitoring into a secret weapon for shipping better software faster.

Explore Better Stack