- Posted on
- • Administration
Scheduling automatic updates with DNF Automatic on RHEL
- Author
-
-
- User
- Linux Bash
- Posts by this author
- Posts by this author
-
Automating System Updates on Linux: A Guide to Using DNF Automatic on RHEL and Beyond
Keeping your Linux systems up-to-date is crucial for security, stability, and accessing new features. However, manually updating packages can be a time-consuming task. Fortunately, several Linux distributions offer tools to automate this process, among which DNF Automatic is prominently used in RHEL (Red Hat Enterprise Linux). In this guide, we will explore how to set up DNF Automatic on RHEL and also briefly discuss automation tools for other package managers like apt
for Debian/Ubuntu-based systems, and zypper
for openSUSE.
Setting Up DNF Automatic on RHEL
DNF Automatic is an extension of DNF, the package manager used in Fedora, RHEL, and CentOS. It allows administrators to schedule and automatically manage package updates. Here's how you can configure it on a RHEL system:
Install DNF Automatic: First, ensure that DNF Automatic is installed on your system. You can install it by running:
sudo dnf install dnf-automatic
Configure DNF Automatic: Configuration files for DNF Automatic are located in
/etc/dnf/automatic.conf
. You need to edit this file to specify how updates should be handled. Open the file in a text editor:sudo nano /etc/dnf/automatic.conf
Configure the necessary parameters under
[commands]
and[emitters]
sections. For example, to apply all updates automatically:[commands] upgrade_type = default random_sleep = 300 [emitters] system_name = MyServer emit_via = email email_from = admin@myserver.com email_to = user@myserver.com email_host = smtp.myserver.com
Schedule DNF Automatic: The easiest way to schedule DNF Automatic is by using the Systemd timer that comes with it:
sudo systemctl enable --now dnf-automatic.timer
This command enables and starts the timer which triggers the
dnf-automatic
service according to the configured schedule.
Automating Updates with Other Package Managers
For systems not using DNF, here are brief instructions on setting up automatic updates using popular package managers like apt
and zypper
.
Using apt
on Debian/Ubuntu:
apt
can be automated using the unattended-upgrades
package.
Install unattended-upgrades:
sudo apt install unattended-upgrades
Configure unattended-upgrades: Edit the configuration file at
/etc/apt/apt.conf.d/50unattended-upgrades
to select which package updates to apply automatically.Enable automatic updates: Enable the automatic updates by editing
/etc/apt/apt.conf.d/20auto-upgrades
and setting the appropriate parameters to start the update.
Using zypper
on openSUSE:
zypper
supports automatic updates using a cron job or systemd timer.
Create a Zypper update script: Write a simple script that calls
zypper up
orzypper patch
to apply updates.Schedule the script using cron or systemd: For cron, add an entry in your crontab. For systemd, create a new timer and service file to execute your script regularly.
Conclusion
Automating package updates is a vital task for maintaining the security and functionality of your Linux systems. Each package manager provides its toolkit for handling this automation efficiently. While DNF Automatic is well-suited for RHEL, tools like unattended-upgrades
and cron or systemd jobs for zypper
effectively serve other distributions. By setting up automatic updates, administrators can ensure their systems are always running the latest software without manual oversight. This contributes greatly to both operational reliability and security.
Further Reading
Here are some recommended further reading resources covering various aspects of package management automation in Linux:
Red Hat Documentation on DNF:
- Detailed overview and documentation from Red Hat about using DNF for package management. Red Hat DNF Documentation
DigitalOcean Tutorial on Unattended-Upgrades for Ubuntu:
- A beginner-friendly guide on setting up
unattended-upgrades
on Ubuntu systems. DigitalOcean Unattended-Upgrades Guide
- A beginner-friendly guide on setting up
openSUSE Wiki on System Updates with Zypper:
- Official openSUSE documentation detailing how to automate updates using Zypper. openSUSE Zypper Automation
Fedora Magazine on Automating System Updates:
- An article from Fedora Magazine discussing how to use DNF Automatic for Fedora, applicable to RHEL systems. Fedora Magazine on DNF Automatic
ArchWiki on Automating Pacman Updates:
- While focused on Arch Linux, this provides useful insights into system update automation that could inform advanced configurations on other distros. ArchWiki on Automated Pacman Updates