3

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?

3
  • Which distro are you using ? – user9517 Dec 3 '15 at 10:40
  • Debian atm, but same goes for Ubuntu and Arch – fdafgfdgfagfdagfdagfdagfdagfda Dec 3 '15 at 14:37
  • Ubuntu changed to systemd between 14.04 and 16.04 - yet the 16.04 version still has the 14.04-type files there with exec cron and uses them WHEN IT HAS BEEN UPGRADED FROM AN ORIGINAL 14.04 INSTALL. – SDsolar Oct 21 '17 at 6:13
5

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.

0
0

For the same in Fedora, follow @Iain’s instructions but edit the CRONDARGS option in /etc/sysconfig/crond instead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.