Enabling automatic updates in Centos 7 and RHEL 7

In previous posts we’ve seen how to Enable automatic security update in Debian/Ubuntu and in Red hat enterprise or Centos 6, recently I’ve started to work with the new Red Hat Enterprise 7 and I’ve noticed that there are some interesting changes in the way this system can be set to auto update.

An example ?

In Red Hat/Centos 6 you could not set which kind of update you’d like to do, so you could just decide to update for any kind of update (feature,bug or security) or nothing at all, this has changed and now we can fine grain which kind of updates we want to do on our servers.



Install yum-cron

The package that allows us to do automatic updates via yum is yum-cron, to do this just open a terminal as root and run the command:

yum -y install yum-cron

This will install the yum-cron package, now it’s time to configure it, the default configuration file it’s /etc/yum/yum-cron.conf.

Configure yum-cron for auto-update

In the first part of the file you’ll find these options (these are the defaults):

#  What kind of update to use:
# default                            = yum upgrade
# security                           = yum --security upgrade
# security-severity:Critical         = yum --sec-severity=Critical upgrade
# minimal                            = yum --bugfix upgrade-minimal
# minimal-security                   = yum --security upgrade-minimal
# minimal-security-severity:Critical =  --sec-severity=Critical upgrade-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 = no

# 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

In my opinion the first it’s the most interesting, while on rhel/centos 6 we were unable to choose which kind of update do in automatic we are plenty of options in rhel/centos 7.

As you can see the default it’s to upgrade all your packages, the same you’d obtain with the command yum upgrade, but there are also other options and now you can decide to just do security upgrade or even just the most critical security, this add a lot of flexibility and options.

As example you can now do full upgrades on your development machines and just the minimum to stay security safe on your production servers, this make sense and it’s good to be finally able to specify this.

How to have an output of the results

There are 2 setup that you can tweak to get feedbacks from this procedure:

1) As first option you can decide to send messages to standard output or via email with the option emit_via

# 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 = stdio

2) If you choose to send the output via email you have some option available to set the most common options for an email:

[email]
# The address to send email messages from.
email_from = root@localhost

# List of addresses to send messages to.
email_to = 

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

Verify that the service is running

Once installed the service should be enabled by default, but to be sure you can verify it with the command systemctl status yum-cron.service that should give an output similar to this one:

# /bin/systemctl status  yum-cron.service
yum-cron.service - Run automatic yum updates as a cron job
   Loaded: loaded (/usr/lib/systemd/system/yum-cron.service; enabled)
   Active: active (exited) since sab 2014-08-09 00:37:16 CEST; 16h ago
  Process: 830 ExecStart=/bin/touch /var/lock/subsys/yum-cron (code=exited, status=0/SUCCESS)
 Main PID: 830 (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/yum-cron.service

If you see that the service is stopped you can start it with the command

systemctl start yum-cron.service

Conclusions

By default this package is not present and so, unless you have a tight schedule and care of updating your servers, I strongly suggest to install and enable it, and keep the most “wide” upgrade option that should not break your services.
As example I’ve a server with apache and php, I know the application and everything is installed from the repositories, I’m “quiet” sure that a full upgrade of the system will not broke anything and so I’ve choose to keep the default option and upgrade all the packages.

On the other way on systems where I don’t know well the applications, or something is installed from the sources I’d keep the automatic upgrades only for security reasons.

0 (0)
Article Rating (No Votes)
Rate this article
Attachments
There are no attachments for this article.
Comments
There are no comments for this article. Be the first to post a comment.
Full Name
Email Address
Security Code Security Code
Related Articles RSS Feed
logrotate Understanding logrotate utility
Viewed 786 times since Sun, Jan 12, 2020
Linux - How to unlock and reset user’s account
Viewed 1103 times since Fri, Jun 8, 2018
Linux get the list of FC HBA’s and WWPN
Viewed 1493 times since Tue, May 22, 2018
Using Kerberos security with Server for NFS
Viewed 6373 times since Wed, Jun 27, 2018
List DNS records, nameservers of a domain from command line
Viewed 855 times since Sun, Sep 30, 2018
RHEL: Reinstalling Boot Loader on the Master Boot Record (MBR)
Viewed 1701 times since Sun, May 27, 2018
How to disable SSH cipher/ MAC algorithms for Linux and Unix
Viewed 17225 times since Fri, Aug 21, 2020
Linux - Cannot login from remote console but can access via ssh
Viewed 2708 times since Fri, Jun 8, 2018
Tcpdump Examples Linux
Viewed 4094 times since Fri, Nov 16, 2018
Understanding logrotate utility part 1
Viewed 829 times since Fri, Nov 30, 2018