1

I have CentOS 7 and am trying to access a configuration file that looks a little something like this:

# Cron configuration options

# For quick reference, the currently available log levels are:
#   0   no logging (errors are logged regardless)
#   1   log start of jobs
#   2   log end of jobs
#   4   log jobs with exit status != 0
#   8   log the process identifier of child process (in all logs)
#

My goal is to disable cron logging.

I've tried googling this and apparently some people have files like /etc/default/cron and /etc/rsyslog.d/50-Default.conf but none of those files exist when I search for them. I do have /etc/rsyslog.conf and tried to use cron.none.* /var/log/messages (I don't have /var/log/syslog either) to disable cron logging, but I'm still getting cron logs on my remote server.

How can I stop the cron logs (but not cron itself)? Nothing I do seems to stop them.

11
  • Have you tried deleting the line for cron logs and then restarting the rsyslog service? There may also be something in /etc/rsyslog.d that is configuring cron logs. Jul 7, 2022 at 14:51
  • @NasirRiley I have commented out the cron.* /var/log/cron line and restarted, but /var/log/cron and /var/log/cron.log both don't have any cron logs anyway. I am still getting cron logs.
    – user532591
    Jul 7, 2022 at 14:55
  • That config file looks like the one used by vixie cron, as used on Debian distro. CentOS does not use that implementation of cron, and so lacks that file and indeed that functionality.
    – steve
    Jul 7, 2022 at 15:14
  • @steve Ah, so it's not possible to access that file? Is there any way to disable cron logging elsewhere? Nothing I've tried everything in /etc/rsyslog.conf seems to work.
    – user532591
    Jul 7, 2022 at 15:19
  • As you've mentioned that you are still getting cron logs, where are they actually being sent? Jul 7, 2022 at 15:31

1 Answer 1

0

CentOS/RHEL 7 use the cronie implementation of cron. The file you show there relates to vixie cron, as used on distributions such as Debian.

[root@centos7 ~]# head -2 /usr/share/doc/cron*/README
17. January 2008        mmaslano (at) redhat (dot) com
Rename the fork on cronie. The source code could be found here:
[root@centos7 ~]#
root@debian:/# head -20 /usr/share/doc/cron*/README
#/* Copyright 1988,1990,1993 by Paul Vixie
# * All rights reserved
# *
# * Distribute freely, except: don't remove my name from the source or
# * documentation (don't take credit for my work), mark your changes (don't
# * get me blamed for your possible bugs), don't alter or remove this
# * notice.  May be sold if buildable source is provided to buyer.  No
# * warrantee of any kind, express or implied, is included with this
# * software; use at your own risk, responsibility for damages (if any) to
# * anyone resulting from the use of this software rests entirely with the
# * user.
# *
# * Send bug reports, bug fixes, enhancements, requests, flames, etc., and
# * I'll try to keep a version up to date.  I can be reached as follows:
# * Paul Vixie          <[email protected]>          uunet!decwrl!vixie!paul
# */

Vixie Cron V3.0
December 27, 1993
[V2.2 was some time in 1992]
root@debian:/#

By default, cronie will send all cron messages to /var/log/cron using the /etc/rsyslog.conf entry below

[root@centos7 ~]# grep ^cron /etc/rsyslog.conf
cron.*                                                  /var/log/cron
[root@centos7 ~]#

To change where they're written, revise the file and restart rsyslog. No need to restart cron.

[root@centos7 ~]# sed -i 's!/var/log/cron!/var/log/bob!' /etc/rsyslog.conf
[root@centos7 ~]# grep ^cron /etc/rsyslog.conf
cron.*                                                  /var/log/bob
[root@centos7 ~]# systemctl restart rsyslog
[root@centos7 ~]# tail /var/log/bob
Jul  7 19:16:41 centos7 crontab[8581]: (root) LIST (root)
Jul  7 19:17:01 centos7 CROND[8587]: (root) CMD (/bin/touch /tmp/foo)
[root@centos7 ~]#

And pointed out by @doneal24 to completely discard the entries, per your original question, you'd use a /etc/rsyslog.conf line such as below

cron.* ~
2
  • 2
    This config redirects the logs to another file but the OP wants the logs stopped. I think the appropriate line is cron.* ~.
    – doneal24
    Jul 7, 2022 at 18:25
  • 1
    Thank you for the thorough answer! Although @doneal24's answer helped me with my goal, I'll mark yours as the solution since yours was the only posted answer. Thanks!
    – user532591
    Jul 7, 2022 at 20:43

You must log in to answer this question.