How to configure Automatic Updates with yum-cron on CentOS 7?

It is very essential to update your Centos system for the security perspective. Your system may become vulnerable if you don't update your OS packages with security patches.

However, managing the manual updates on multiple OS may take some time. To overcome this, you can set automatic updates. Please refer to the following steps to configure automatic updates on CentOS 7. 

  1. At first, we will install yum-cron that will help you to set automatically run the yum command. Your system may already have the same package installed. 

    # sudo yum install yum-cron
  2. Enable and start the yum-cron.

    # sudo systemctl enable yum-cron
    # sudo systemctl start yum-cron
  3. Verify the service is running with the below command. 

    # systemctl status yum-cron

There will be two configuration files inside the /etc/yum directory. yum-cron-hourly.conf for hourly and yum-cron.conf. for the yearly configuration file. Yum-cron will manage the cron to be run or not.

  1. Open the yum-cron-hourly.conf file in your favorite text editor and in the command section, define the types of packages that need to be updated, enable messages and downloads, and set to automatically apply updates when it is available. Update_cmd will be set to the default which will update all packages. It is recommended to change the value to security so yum will update the packages which have a security issue..

    # nano /etc/yum/yum-cron-hourly.conf
    [commands]
    update_cmd = security
    update_messages = yes
    download_updates = yes
    apply_updates = no
    random_sleep = 360
    
  2. In the second section, you can define to send messages to stdout and email change.

    [emitters]
    system_name = None
    emit_via = stdio,email
    output_width = 80
  3. Set the send and receiver email address. You need to have a tool that can send emails from your system such as postfix or mailx.

    [email]
    email_from = [email protected]
    email_to = [email protected]
    email_host = localhost
  4. At base section, you can modify the settings defined in yum.conf file. Incase, you want to exclude any packages, you can add it inside the base. Here, we have excluded [mariadb] package.

    [base]
    debuglevel = -2
    mdpolicy = group:main
    exclude = mariadb*
  5. You can use grep to check whether cron jobs for yum are executed.

    sudo grep yum /var/log/cron

Related Articles

How to Install Joomla from Softaculous in cPanel?

Joomla is an open-source and a popular CMS. It is a very easy process to build a joomla template....

How to install Google Chrome on Ubuntu 18.04 using the Command Line?

Following are the steps to install Google Chrome using Command-Line. Edit the source.list file...

Fix :: SSH Error: Starting sshd: Missing privilege separation directory: /var/empty/sshd

Problem Statement Could not connect to Linux machine through SSH. Error Message While starting...

How to configure 2FA on Magento 2.x Admin Panel using Google Authenticator?

Two-factor authentication is a proven security standard to add additional security to your login...

How to install IonCube Loader on CentOS 7 Manually?

Ioncube is a PHP module which protects the PHP application's source code from being viewed from...

  • 0 Users Found This Useful

Was this answer helpful?