Unpatched servers are compromised servers — most breaches exploit vulnerabilities that had fixes available for weeks. Setting up automatic updates on Rocky Linux 9 with dnf-automatic removes the human delay for security patches while keeping you in control of how and when they are applied. This guide covers installation, the configuration file, systemd timers, email reporting and a safe rollout strategy.
How dnf-automatic Provides Automatic Updates on Rocky Linux 9 – How to Enable Automatic Security Updates
dnf-automatic is a small companion to DNF. Depending on the timer you enable, it can:
- download updates in the background so your manual upgrade is fast,
- download and notify you by email or log output, or
- download and install updates completely unattended.
You can also restrict it to security updates only, which is the sweet spot for most servers.
Step 1: Install dnf-automatic – How to Enable Automatic Security Updates
sudo dnf install -y dnf-automatic
systemctl status dnf-automatic-install.timer
The package installs the configuration file and three systemd timers, all disabled until you enable the one you want.
Step 2: Configure /etc/dnf/automatic.conf
Edit the file and review the important options:
[commands]
upgrade_type = security
random_sleep = 300
apply_updates = no
download_updates = yes
[emitters]
emit_via = email
[email]
email_from = [email protected]
email_to = [email protected]
email_host = localhost
Key choices explained:
upgrade_type = securityinstalls only updates flagged as security fixes. Usedefaultto apply every update.apply_updatesonly matters for the “install” timer; leaving itnowith the download timer gives you a download-only setup.random_sleepspreads the load so a fleet of servers does not hit mirrors at the same second.

Step 3: Enable the Right Timer
Pick exactly one timer depending on the behaviour you configured:
# Download only:
sudo systemctl enable --now dnf-automatic-download.timer
# Download and apply (for the automatic updates on Rocky Linux 9 setup):
sudo systemctl enable --now dnf-automatic-install.timer
# Download and only notify:
sudo systemctl enable --now dnf-automatic-notifyonly.timer
Verify it is scheduled:
systemctl list-timers | grep dnf
journalctl -u dnf-automatic-install.service --since today
Step 4: Handle Reboots and Running Services
Kernel and core library updates need a reboot or service restarts to take effect. dnf-automatic will not reboot the server for you (which is good). Check what is pending with:
sudo dnf needs-restarting
sudo dnf needs-restarting -r
The -r flag reports whether a reboot is required. Build a habit: let dnf-automatic patch during the week, then reboot in a planned window — our backup automation guide follows the same maintenance-window philosophy. Pairing patching with the Rocky Linux 9 hardening checklist keeps the whole routine consistent.
A Safe Rollout Strategy
- Week 1: enable the download timer plus email reports. Read what would be installed.
- Week 2: switch non-critical servers (monitoring, staging, file servers) to the install timer with
upgrade_type = security. - Later: extend to production web and database servers, keeping a manual reboot schedule.
Skip automatic installation entirely for machines running clustered databases or anything whose vendor demands certified patch levels.
Troubleshooting
- The timer shows as enabled but nothing happens: check
systemctl status dnf-automatic-install.timerand the journal. A common mistake is enabling two timers at once. - No emails arrive: the server needs a working local mail setup or a relay. Test with
mailor configureemail_hostto your SMTP relay. Alternatively setemit_via = stdioand read reports in the journal. - An update broke an application: roll back with DNF history:
sudo dnf history undo <id>, as shown in our DNF repositories guide. - Updates conflict with version-locked packages: review
dnf versionlock listand exclude those packages deliberately.
Excluding Packages from Automatic Updates
Some software must only change during planned maintenance — database servers are the classic example. There are two ways to hold packages back. The global way is the versionlock plugin described in our DNF repositories guide; dnf-automatic respects versionlocks just like interactive DNF. The targeted way is an exclude line in /etc/dnf/automatic.conf:
[commands]
exclude = mariadb*,galera*
Excluded packages are still reported in the notification output, so you see that a MariaDB security fix exists and can schedule it manually instead of being surprised by it later.
Watching dnf-automatic Work
On servers with Cockpit enabled, the Software Updates page shows pending updates and their severity, which pairs nicely with email reports. Without a GUI, the journal is your dashboard:
journalctl -u 'dnf-automatic*' --since "7 days ago"
grep -i "upgrade" /var/log/dnf.log | tail
Once a month, skim these logs to confirm the timers fired, the downloads succeeded and no update is stuck failing repeatedly on the same dependency problem.
Conclusion
Automatic updates on Rocky Linux 9 take ten minutes to set up and quietly remove the biggest routine risk to your servers. Start with download-and-report, graduate to security-only auto-install, and keep control of reboots. For the wider picture, the Rocky Linux documentation covers system maintenance and update policy in detail.
One last recommendation: document your policy. A short note in your server documentation — which timer is enabled, which packages are excluded, who receives the email reports and when planned reboots happen — turns an invisible background process into an auditable part of your operations. When a colleague asks “are we patched?”, the answer should take seconds, not an investigation.