How to change cron log level?
I replaced exec cron
with exec cron -L 15
the run sudo service cron reload
, sudo service cron restart
but nothing changed. Cron doesn't log the end of jobs and doesn't log failed jobs. I hade no problem in Ubuntu 14.04, but now I have this problem in Ubuntu 16.04. What do I do wrong?
Step by Step: First I changed /etc/init/cron.conf:
sudo sed -i 's|exec cron$|exec cron -L15|' /etc/init/cron.conf && sudo restart cron && cat /etc/init/cron.conf
So now it is
$ cat /etc/init/cron.conf
# cron - regular background program processing daemon
#
# cron is a standard UNIX program that runs user-specified programs at
# periodic scheduled times
description "regular background program processing daemon"
start on runlevel [2345]
stop on runlevel [!2345]
expect fork
respawn
exec cron -L 15
I made the same config in my Ubuntu 16.04 as well as on Ubuntu 14.04 on the another PC.
The Cron log in Ubuntu 14.04 is the following:
$ grep CRON /var/log/syslog
Aug 26 16:05:01 y1404 CRON[6825]: (y) CMD (foo # JOB_ID_1)
Aug 26 16:05:01 y1404 CRON[6824]: (CRON) error (grandchild #6825 failed with exit status 127)
So you can see the second line with error notification about nonexistent command foo
. But in Ubuntu 16.04 there is no error notification in the log:
Aug 26 16:25:01 my CRON[7259]: (y) CMD (foo # JOB_ID_129)
From Ubuntu 15.04 on, upstart using /etc/init/*.conf
is replaced by systemd using configuration files in /lib/systemd/system/
and /etc/systemd/system/
. Although a file /etc/init/cron.conf
is still existent in Ubuntu 16.04, the script normally in use to start cron
now is /lib/systemd/system/cron.service
. If you want to add extra options, edit this file with
sudo systemctl edit --full cron
and replace the line
ExecStart=/usr/sbin/cron -f $EXTRA_OPTS
by e. g.
ExecStart=/usr/sbin/cron -L 15 -f $EXTRA_OPTS
To reload the configuration, run sudo systemctl restart cron
or just reboot. You can test what exact command a service was started with using systemctl status
, e. g. for cron
(see last line):
> systemctl status cron
● cron.service - Regular background program processing daemon
Loaded: loaded (/lib/systemd/system/cron.service; enabled; vendor preset: enabled)
Active: active (running) since So 2017-08-27 09:56:18 CEST; 1h 15min ago
Docs: man:cron(8)
Main PID: 26021 (cron)
CGroup: /system.slice/cron.service
└─26021 /usr/sbin/cron -f