Guides / Linux servers

Automatic security updates on RHEL, Rocky Linux and AlmaLinux with dnf-automatic

beginnerUpdated 26 Nov 2026646 words

dnf-automatic downloads and installs package updates from a systemd timer. With upgrade_type = security, it installs only the updates that come with a security advisory, which keeps the changes small. The setup below is for RHEL, Rocky Linux and AlmaLinux; it was tested on Rocky Linux 9.9 and 10.3, which use dnf 4 and the same dnf-automatic package as RHEL.

Install

sudo dnf install dnf-automatic

Configure

The configuration is /etc/dnf/automatic.conf. The file that Rocky Linux 9 and 10 ship downloads updates but does not install them (download_updates = yes, apply_updates = no), and it covers all updates (upgrade_type = default). Change these lines:

[commands]
upgrade_type = security
download_updates = yes
apply_updates = yes
reboot = never

[emitters]
emit_via = stdio
Setting Meaning
upgrade_type = security Only updates with a security advisory. default installs all updates.
apply_updates = yes Install the updates, not only download them.
reboot never, when-changed (after any update) or when-needed (after updates that need a reboot, such as the kernel or glibc). The reboot runs shutdown -r +5 by default (reboot_command).
emit_via = stdio Write the report to the output of the service, which ends up in the journal. email needs a working mail setup, motd writes to the login message.

Turn on the timer

sudo systemctl enable --now dnf-automatic.timer
systemctl list-timers 'dnf-automatic*'

dnf-automatic.timer follows the configuration file. The package also ships timers that ignore apply_updates and download_updates: dnf-automatic-notifyonly.timer (report only), dnf-automatic-download.timer and dnf-automatic-install.timer. Enable one timer, not several.

All four timers run at 06:00 with a random delay of up to 60 minutes (OnCalendar=*-*-* 6:00, RandomizedDelaySec=60m) and catch up after downtime (Persistent=true), as shipped on Rocky Linux 9 and 10.

To run at a different time, override the timer:

sudo systemctl edit dnf-automatic.timer
[Timer]
OnCalendar=
OnCalendar=*-*-* 03:30

The empty OnCalendar= clears the time of the packaged timer before the new one is set.

Check what it would install

The security filter depends on the advisories (updateinfo) of the repositories. Red Hat publishes RHSA advisories, Rocky Linux RLSA, AlmaLinux ALSA. To see what is pending:

sudo dnf updateinfo list --security
sudo dnf check-update --security

dnf check-update exits with code 100 when updates are available and 0 when there are none.

Packages from repositories without advisories never count as security updates. With upgrade_type = security, they are not installed automatically. Update them on a schedule of your own, or set upgrade_type = default.

Check that it ran

journalctl -u dnf-automatic.service --since -2d
sudo dnf history list | head

The journal shows the report of each run, ending with a line such as Updates completed at Thu Nov 26 02:52:43 2026; dnf history lists the transactions with their date.

Reboots

Kernel and glibc updates need a reboot. dnf needs-restarting -r tells whether the server needs one (exit code

  1. or not (exit code 0). With reboot = when-needed, dnf-automatic reboots on its own after such updates; the reboot guide covers how to plan it and make sure services come back.

Amazon Linux 2023

Amazon Linux 2023 locks each server to the repository version of the AMI it was built from, and every new set of package updates is a new repository version. dnf-automatic alone then finds nothing to install. List the newer versions and move to one with:

sudo dnf check-release-update
sudo dnf upgrade --releasever=<version>

Patchbrief checks every day that dnf-automatic or another update timer is active and counts the security updates that are still waiting.

Sources

Check your servers every day

The agent of Patchbrief reports the packages and settings of a server once a day; the digest names what to fix first.

Start free