11

Every day, I get the following mail delivered by postfix:

From: Anacron <root@name.domain>
To: root@name.domain
Subject: Anacron job 'cron.daily' on name
Content-Type: text/plain; charset=US-ASCII
Message-Id: <20130708082739.88AE83A3F72@name.domain.domain>
Date: Mon,  8 Jul 2013 10:27:39 +0200 (CEST)

/etc/cron.daily/ntpdate:
 8 Jul 10:27:39 ntpdate[4617]: step time server 85.254.216.1 offset -1.454673 sec

However, I'd like to limit anacron to only warn me if something is wrong. Is there any way to accomplish this? I could change the anacrontab file to send all mails to /dev/null, but then I'd get no warning mails whatsoever.

Is there a better way to control the granularity of anacron status updates?

8

Anacron sends emails only if cron jobs produce some output. If you are not interested in some of the messages you need to filter it yourself by modifying appropriate script in one of /etc/cron.* (i.e. /etc/cron.daily/) directories.

If you don't want to see updates from /etc/cron.daily/ntpdate - edit the file and redirect standard output of command to /dev/null or better to a log file because you may want to check it in the future or do some custom filtering that would suite you. If you want to be notified about some erroneous conditions you should probably not redirect standard error stream, so it can be included in cron email report.

2

Cron jobs (including Anacron's jobs) are standarised to report by email any output.

For commands like ntpdate which output when no errors occur, one can use cronic, which will suppress such output but still report by email on errors!

Copy the cronic script from the link above to /usr/local/bin, check that it does only what it is supposed to do (for security reasons), and modify /etc/cron.daily/ntpdate prefixing /usr/local/bin/cronic to the ntpdate command.

0

There are two settings in yum-cron to look out for in terms of emails:

# Whether a message should be emitted when updates are available,
# were downloaded, or applied.
update_messages = no

# Use this to filter Yum core messages
# -4: critical
# -3: critical+errors
# -2: critical+errors+warnings (default)
debuglevel = -3

With update_messages yes, you'll almost always get emails. I set debuglevel = -3 in yum-cron-hourly.conf to suppress erratic emails such as yum.pid: another copy is running as pid 29904.

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.