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

Better Stack Team
Updated on October 5, 2023

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.

🔭 Want to get alerted when your Cron doesn’t run correctly?

Go to Better Stack and start monitoring in 5 minutes.

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.


Make your mark

Join the writer's program

Are you a developer and love writing and sharing your knowledge with the world? Join our guest writing program and get paid for writing amazing technical guides. We'll get them to the right readers that will appreciate them.

Write for us
Writer of the month
Marin Bezhanov
Marin is a software engineer and architect with a broad range of experience working...
Build on top of Better Stack

Write a script, app or project on top of Better Stack and share it with the world. Make a public repository and share it with us at our email.

or submit a pull request and help us build better products for everyone.

See the full list of amazing projects on github