Keeping your server updated is a crucial part of maintaining system security and stability. This might seem a daunting task, especially if you’re dealing with multiple servers. However, Red Hat Enterprise Linux (RHEL) provides a simple and effective solution for automatic updates: yum-cron
.
In this article, we will walk you through setting up yum-cron
on a RHEL 7 host to automate your OS package updates.
Step 1: Install the yum-cron
package
First, we need to install the yum-cron
package. This package allows the system to automatically perform actions such as checking for, downloading, and applying updates. You can install it by running the following command:
sudo yum install yum-cron
Step 2: Configure yum-cron
Next, we need to modify the yum-cron
configuration file. This file, located at /etc/yum/yum-cron.conf
, dictates how yum-cron
behaves.
Open the file using a text editor of your choice. Here, we’ll use vi
:
sudo vi /etc/yum/yum-cron.conf
There are several options you may wish to adjust according to your requirements:
update_cmd
: This defines the type of updates to apply. Options includedefault
(all updates),security
(only security updates),security-severity:Critical
(only critical security updates), orminimal
(minimal updates).download_updates
: Set this toyes
to enable automatic downloading of updates.apply_updates
: If you wantyum-cron
to install updates automatically, set this toyes
.
For example, to have yum-cron
automatically install all updates, use these settings:
update_cmd = default
download_updates = yes
apply_updates = yes
Save your changes and close the file once you’ve finished editing.
Step 3: Enable and Start the yum-cron
service
Lastly, we need to enable yum-cron
to start at boot, and start the service immediately. To do this, run the following commands:
sudo systemctl enable yum-cron
sudo systemctl start yum-cron
With these steps completed, yum-cron
is set to keep your system updated automatically.
You can verify the status of the yum-cron
service at any time by running sudo systemctl status yum-cron
.
Conclusion
Setting up yum-cron
for automatic updates can greatly simplify the task of keeping your RHEL 7 host updated. This not only saves time but also ensures that you promptly receive important updates, increasing your system’s security and stability. Happy updating!