emails to myself when Yum updates my centos

General support questions
Post Reply
Posts: 7
Joined: 2017/09/16 15:49:02

emails to myself when Yum updates my centos

Post by barneybloggs » 2018/05/26 13:31:15

Hi all,
Ive got a personal Centos7 server which is not part of a domain.
I only use it on my family network.
I thought it would be cool if I could setup email notification when yum downloads and installs updates.
Yum updates are running via a cron job which works perfectly.
i installed SSMTP which is working OK and I have sent and successfully received a test email I sent.
Yum has just done an update, but I received no email notification.

Here's the ssmtp.conf
# /etc/ssmtp.conf -- a config file for sSMTP sendmail.
# See the ssmtp.conf(5) man page for a more verbose explanation of the
# available options.
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.

# The place where the mail goes. The actual machine name is required
# no MX records are consulted. Commonly mailhosts are named
# The example will fit if you are in and your mailhub is so named.

# Example for SMTP port number 2525
AuthPass= <--- removed
# Example for SMTP port number 25 (Standard/RFC)
# mailhub=mail.your.domain
# Example for SSL encrypted connection
# mailhub=mail.your.domain:465

# Where will the mail seem to come from?

# The full hostname

# Set this to never rewrite the "From:" line (unless not given) and to
# use that address in the "from line" of the envelope.

# Use SSL/TLS to send secure messages to server.
#IMPORTANT: The following line is mandatory for TLS authentication

# Use SSL/TLS certificate to authenticate against smtp host.

# Use this RSA certificate.

# Get enhanced (*really* enhanced) debugging information in the logs
# If you want to have debugging of the config file parsing, move this option
# to the top of the config file and uncomment

And here's my yum.conf

bugtracker_url= ... tegory=yum

# This is the default, if you make this bigger yum won't see if the metadata
# is newer on the remote and so you'll "gain" the bandwidth of not having to
# download the new metadata and "pay" for it by yum not having correct
# information.
# It is esp. important, to have correct metadata, for distributions like
# Fedora which don't keep old packages around. If you don't like this checking
# interupting your command line usage, it's much better to have something
# manually check the metadata once an hour (yum-updatesd will do this).
# metadata_expire=90m

# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d

And heres an extract of the latest yum update log
May 26 11:22:08 Updated: scap-security-guide.noarch 0.1.36-9.el7.centos
May 26 11:22:09 Updated: procps-ng.x86_64 3.3.10-17.el7_5.2
May 26 11:22:30 Installed: kernel.x86_64 3.10.0-862.3.2.el7
May 26 11:22:31 Updated: microcode_ctl.x86_64 2:2.1-29.2.el7_5

I appreciate you looking at this for me and, hopefully, spotting anything wrong.
If you need any further logs to assist please let me know and I will gladly share.


Posts: 1135
Joined: 2015/02/17 15:14:33
Location: Bulgaria

Re: emails to myself when Yum updates my centos

Post by hunter86_bg » 2018/05/26 15:11:42

I don't see any feature to send an email in yum ,so you need to define it into your cron job. Can you give details how you send the e-mail ?

User avatar
Forum Moderator
Posts: 2507
Joined: 2010/12/01 19:25:52
Location: Helsinki, Finland

Re: emails to myself when Yum updates my centos

Post by avij » 2018/05/26 16:02:41

If you have logwatch installed, it can send such notices. Typically once per day, though.

Code: Select all

 --------------------- yum Begin ------------------------ 

 Packages Updated:
 ---------------------- yum End ------------------------- 

User avatar
Forum Moderator
Posts: 22748
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: emails to myself when Yum updates my centos

Post by TrevorH » 2018/05/26 16:31:03

yum-cron can email
CentOS 5 died in March 2017 - migrate NOW!
Full time Geek, part time moderator. Use the FAQ Luke

Posts: 7
Joined: 2017/09/16 15:49:02

Re: emails to myself when Yum updates my centos

Post by barneybloggs » 2018/05/27 01:25:32

TrevorH: yum-cron can email

Here's my yum-cron.conf
I have made one small change which hopefully will 'fix' the issue see [emitters] section:

# What kind of update to use:
# default = yum upgrade
# security = yum --security upgrade
# security-severity:Critical = yum --sec-severity=Critical upgrade
# minimal = yum --bugfix update-minimal
# minimal-security = yum --security update-minimal
# minimal-security-severity:Critical = --sec-severity=Critical update-minimal
update_cmd = default

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

# Whether updates should be downloaded when they are available.
download_updates = yes

# Whether updates should be applied when they are available. Note
# that download_updates must also be yes for the update to be applied.
apply_updates = yes

# Maximum amout of time to randomly sleep, in minutes. The program
# will sleep for a random amount of time between 0 and random_sleep
# minutes before running. This is useful for e.g. staggering the
# times that multiple systems will access update servers. If
# random_sleep is 0 or negative, the program will run immediately.
# 6*60 = 360
random_sleep = 360

# Name to use for this system in messages that are emitted. If
# system_name is None, the hostname will be used.
system_name = None

# How to send messages. Valid options are stdio and email. If
# emit_via includes stdio, messages will be sent to stdout; this is useful
# to have cron send the messages. If emit_via includes email, this
# program will send email itself according to the configured options.
# If emit_via is None or left blank, no messages will be sent.
emit_via = ssmtp <--- I have now changed this option to email hopefully this will work!!??

# The width, in characters, that messages that are emitted should be
# formatted to.
output_width = 80

# The address to send email messages from.
# NOTE: 'localhost' will be replaced with the value of system_name.
email_from = localhost

# List of addresses to send messages to.
email_to =

# Name of the host to connect to to send email messages.
email_host =

# NOTE: This only works when group_command != objects, which is now the default
# List of groups to update
group_list = None

# The types of group packages to install
group_package_types = mandatory, default

# This section overrides yum.conf

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

# skip_broken = True
mdpolicy = group:main

# Uncomment to auto-import new gpg keys (dangerous)
# assumeyes = True


Posts: 7
Joined: 2017/09/16 15:49:02

Re: emails to myself when Yum updates my centos

Post by barneybloggs » 2018/05/27 13:42:09

Hi all,
Quick update.
The cron job ran early this morning but did not trigger an email.
Im sure this may be because I didnt restart the yum-cron.service. My bad.
Anyway, ive restarted the service now and am waiting for the cron job to run again and install something

yum-cron.service - Run automatic yum updates as a cron job
Loaded: loaded (/usr/lib/systemd/system/yum-cron.service; enabled; vendor preset: disabled)
Active: active (exited) since Sun 2018-05-27 14:30:38 BST; 12s ago
Process: 1118 ExecStop=/bin/rm -f /var/lock/subsys/yum-cron (code=exited, status=0/SUCCESS)
Process: 1120 ExecStart=/bin/touch /var/lock/subsys/yum-cron (code=exited, status=0/SUCCESS)
Main PID: 1120 (code=exited, status=0/SUCCESS)

May 27 14:30:38 centsrv systemd[1]: Starting Run automatic yum updates as a cron job...
May 27 14:30:38 centsrv systemd[1]: Started Run automatic yum updates as a cron job.


Post Reply