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:

  1. Install DNF Automatic: First, ensure that DNF Automatic is installed on your system. You can install it by running:

    sudo dnf install dnf-automatic
    
  2. 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
    
  3. 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.

  1. Install unattended-upgrades:

    sudo apt install unattended-upgrades
    
  2. Configure unattended-upgrades: Edit the configuration file at /etc/apt/apt.conf.d/50unattended-upgrades to select which package updates to apply automatically.

  3. 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.

  1. Create a Zypper update script: Write a simple script that calls zypper up or zypper patch to apply updates.

  2. 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:

  1. Red Hat Documentation on DNF:

  2. DigitalOcean Tutorial on Unattended-Upgrades for Ubuntu:

  3. openSUSE Wiki on System Updates with Zypper:

  4. Fedora Magazine on Automating System Updates:

  5. 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