Reduce cron log level with systemd

journaldsystemd

Googling for a solution, I only found articles telling me how to do it in old systems and not under a systemd maintained Linux, by changing the cron init-script adding -L parameter to the command line.

I have a cron job that runs every minute. It logs every start and additionall a pam_unix-entry for each session opened and closed for the user running cron. This is a lot of babbeling in the journald log. How can I set the log level in a systemd-environment, that I only get errors and fatalities documented?

Best Answer

Ok so I only have EL systems to hand but I asked a friend who as a Debian 8 system and the answer is broadly the same.

For Debian using cron (substitute crond for EL)

systemctl status cron 
systemctl status cron
cron.service - Regular background program processing daemon
   Loaded: loaded (/lib/systemd/system/cron.service; enabled)
   Active: active (running) since Mon 2015-11-02 21:13:22 CET; 1 months 0 days ago
     Docs: man:cron(8)
 Main PID: 983 (cron)
   CGroup: /system.slice/cron.service
           983 /usr/sbin/cron -f

If you then look at the contents of /lib/systemd/system/cron.service

[Unit]
Description=Regular background program processing daemon
Documentation=man:cron(8)

[Service]
EnvironmentFile=-/etc/default/cron
ExecStart=/usr/sbin/cron -f $EXTRA_OPTS
IgnoreSIGPIPE=false
KillMode=process

[Install]
WantedBy=multi-user.target

You can see that it loads an environment file /etc/default/cron amd from that file it uses $EXTRA_OPTS

If your cron daemon supports it you can provide an option to change the logging verbosity there

EXTRA_OPTS="-L 0"

The man page for your distro's cron(d)(8) should tell you what logging options you have.