Ubuntu Create a cron.log File To Log crontab Logs [16.04/18.04/20.04]

To create a “cron.log” file to log crontab logs on Ubuntu 16.04, 18.04, and 20.04, you can use the following steps:

  1. Create the “cron.log” file:
# touch /var/log/cron.log
  1. Change the ownership of the file to the syslog user:
# chown syslog:adm /var/log/cron.log
  1. Edit the syslog configuration file:
# nano /etc/rsyslog.d/50-default.conf
  1. Add the following line to the end of the file:
cron.* /var/log/cron.log
  1. Restart the syslog service to apply the changes:
# service rsyslog restart

That’s it! The “cron.log” file will now log all crontab logs. You can view the logs using the following command:

# tail -f /var/log/cron.log

Note that these steps assume that you are using the default syslog implementation on Ubuntu. If you are using a different logging system, the steps to configure crontab logging may differ.

Leave a Comment