Hello, friends. In this post, you will learn how to schedule system updates in CentOS / RockyLinux. Thanks to this, you will have an improved way to perform this system task.
Upgrading the operating system is a basic task to make it a little more secure and stable. Because this process installs the necessary updates to fix bugs and increase the reliability of the system.
Although it is a quick process to do, it can often be forgotten in the hustle and bustle of work and/or study. So we can always have some tools to help us automate the process.
If you use CentOS 7 / 8 or any distribution of the RHEL family you may notice that if you go many days without updating the system, it suggests you install dnf-cron
or yum-cron
according to the version of the system.
So, I will show you how to use these tools to schedule system updates.
Schedule system updates in CentOS / RockyLinux
Before using these tools we have to install them on the system. The command will depend on the version of RHEL we are using.
In the case of using RHEL 6 / 7 or CentOS 6 / 7, you have to open a terminal and run
sudo dnf install yum-cron
But if you are using RHEL 8 / CentOS 8 / RockyLinux 8 or any derivative of this family, you have to run
sudo dnf install dnf-automatic
Then you have to configure it a little bit.
The configuration file for yum-cron
is /etc/yum/yum-cron.conf
and for dnf-automatic
is /etc/dnf/automatic.conf
.
According to your system, you have to edit one of the two files to make the proper configuration.
In those files, the apply_updates
directive has to be assigned a value of yes
to enable the update.
apply_updates = yes
If you want it to apply immediately then you have to change the value of random_sleep
.
random_sleep = 0
Be careful with this value because as soon as you save the changes it will start the update process. So sometimes it is better to give another value.
Although you installed and set up yum-cron as root, the schedule doesn’t affect the root’s crontab. So be very careful when doing these updates.
Before closing the file you may want to configure the application to only apply security updates. I think this is the best thing to do because then we will be sure that the most important and secure updates will be applied.
To do this, just uncomment the minimal-security
directive
minimal-security = dnf --security update-minimal
Save the changes and close the editor.
Conclusion
This utility allows us to automatically update the operating system. This will make that we can forget about this for a while and everything very secure.
More info in this link