Home AlmalinuxHow to Set Up Automatic Updates on AlmaLinux 9 with DNF Automatic

How to Set Up Automatic Updates on AlmaLinux 9 with DNF Automatic

by Knowledge Base Linux
How to Set Up Automatic Updates — How to Set Up Automatic Updates on AlmaLinux 9 with DNF Automatic

Unpatched servers are the most common way intruders get in — yet manual updates are the first chore skipped on a busy week. The answer on AlmaLinux is dnf-automatic on AlmaLinux 9: a small systemd-driven tool that checks for updates on a schedule, downloads them, and can apply them automatically while reporting everything it did. This guide shows how to install it, choose a safe update policy, and verify it is working. This article covers How to Set Up Automatic Updates in detail.

What DNF Automatic Can Do – How to Set Up Automatic Updates

The tool separates three decisions: whether to download updates, whether to apply them, and how to notify you. You can start conservatively (download only, email a report) and graduate to full automatic application for security updates once you trust the setup. Timers replace the old cron-based yum-cron approach from CentOS 7.

Step 1: Install DNF Automatic – How to Set Up Automatic Updates

sudo dnf install -y dnf-automatic

The package provides the service, its timers and the configuration file /etc/dnf/automatic.conf.

Step 2: Configure the Update Policy

Edit /etc/dnf/automatic.conf. The key settings for a typical server:

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

[emitters]
emit_via = email

[email]
email_from = [email protected]
email_to = [email protected]
email_host = localhost

upgrade_type = security limits automatic installation to security fixes — the safest default for production, because feature updates wait for your review. Use upgrade_type = default only on non-critical machines. This choice is the heart of a sane dnf-automatic on AlmaLinux policy.

DNF Automatic on AlmaLinux calendar-based update automation

Step 3: Enable the Timer

DNF Automatic runs from a systemd timer rather than the daemon-style service:

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

The timer triggers daily at a randomized early-morning time. You can check the next run and the last execution in the list-timers output.

Step 4: Control Reboots

Kernel and core-library updates need a reboot to take effect. By default dnf-automatic never reboots — it applies what it can and leaves the rest pending. Check whether a reboot is required with:

sudo needs-restarting -r

If you manage the server through a provider console and accept automatic reboots in a maintenance window, set reboot = when-needed and reboot_time = "03:00" in the [commands] section. Most administrators prefer to reboot manually after reading the email report — combine this with a monthly review of disk and log growth (see our note on clearing the journal log) to keep maintenance tidy.

Step 5: Verify It Works

Run the service once manually and inspect the results:

sudo systemctl start dnf-automatic.service
sudo journalctl -u dnf-automatic --since today

You should see the check, any downloaded or applied packages, and the emitted report. Also confirm the timer is listed as active. From now on, unread update debt stops accumulating silently — an important complement to the hardening steps in our AlmaLinux server setup guide.

Alternative and Complementary Approaches

Cockpit’s web console can display and apply updates graphically, and configuration-management tools such as Ansible give you fleet-wide orchestration. DNF Automatic remains the best fit for a single server or a small fleet: zero extra infrastructure, distribution-native, and auditable through the journal.

Troubleshooting

Timer enabled but nothing happens: check systemctl status dnf-automatic.timer and that the machine is actually on at the scheduled time; laptops and suspended VMs miss timers. No email reports: verify local mail delivery with a test message, or switch emit_via to stdio/motd while you fix SMTP. Updates download but never apply: you likely left apply_updates = no in automatic.conf — the download-only mode is the factory default. The AlmaLinux wiki documents related update workflows for each release.

Notification-Only Mode and Custom Schedules

If automatic application still feels risky for a particular machine, run dnf-automatic in notification-only mode: set download_updates = yes and apply_updates = no. The timer downloads everything and emails you a report of pending updates, so your manual maintenance window becomes a quick review-and-apply instead of a long download wait. Many teams use notify-only on database servers and full automation on web nodes — the same tool, two risk postures.

You can also move the schedule. The stock timer fires around 6 a.m. with a randomized delay; to pin updates to your own maintenance window, create a timer override:

sudo systemctl edit dnf-automatic.timer
[Timer]
OnCalendar=
OnCalendar=Sun 02:30

Reload systemd with sudo systemctl daemon-reload and confirm with systemctl list-timers. A predictable window makes it far easier to correlate any odd behavior with the updates that were just applied.

Whichever mode you choose, keep one manual ritual: once a month, run sudo dnf history and skim what the automation installed. The history log shows every transaction with timestamps, and sudo dnf history undo <id> can reverse a specific update set if one ever misbehaves. Automation you can audit and undo is automation you can trust — which is precisely the goal.

Conclusion

Setting up dnf-automatic on AlmaLinux takes ten minutes and removes an entire class of risk: install it, apply security updates automatically, get an email report for every run, and reboot on your own schedule. It is the highest-value automation you can add to a small AlmaLinux server.

You may also like

KbLinux

Typically replies within a day

Hello, Welcome to the site. Please click below button for chatting me through Telegram.