Skip to content
TrySitePrice

How to enable automatic updates for RHEL/CentOS 8

Best/Tutorial

In Red Hat Enterprise Linux (RHEL) and CentOS 8, you can enable automatic updates using the "dnf-automatic" package, which is a package that runs automatic updates and provides various options for configuring the update schedule and behavior. To enable automatic updates on RHEL/CentOS 8, you can follow these steps:

  1. Install the "dnf-automatic" package by running the following command:

sudo dnf install dnf-automatic

  1. Start the "dnf-automatic" service and enable it to start automatically at boot time using the following commands:

sudo systemctl start dnf-automatic.timer

sudo systemctl enable dnf-automatic.timer

  1. Configure the update schedule by editing the file /etc/dnf/automatic.conf, you can set the download_updates and apply_updates options to true and set the update_cmd option to "upgrade" to automatically download and install available updates.

download_updates = true

apply_updates = true

update_cmd = upgrade

  1. Configure the update behavior by editing the file /etc/dnf/dnf.conf, you can set the "best" value for the "installonly_limit" option to keep only the latest version of packages installed, and "clean_requirements_on_remove" to true to remove unneeded packages when updates are applied.

installonly_limit = 3

clean_requirements_on_remove = true

  1. To check the status of automatic updates, you can run the following command:

systemctl status dnf-automatic.timer

  1. To check the logs of automatic updates, you can run the following command:

journalctl -u dnf-automatic.timer

It is important to note that automatic updates can cause unexpected downtime, so it is recommended to test updates before deploying them in a production environment. Additionally, you should monitor the update process to ensure that updates are applied as expected and that there are no issues.