DNF-Automatic – Schedule Updates for Fedora (and other Linux distros)

DNF-Automatic – Schedule Updates for Fedora (and other Linux distros)

If you want to have Fedora (and other rpm-based distros) update itself, you can use DNF-Automatic. First, we’ll need to install it. I’ll assume that this is a fresh server and you decided to login as root to get everything configured.

# dnf -y install dnf-automatic

Now that it is installed, we will edit the automatic.conf config file with nano-

# nano /etc/dnf/automatic.conf

You will notice that there are several sections. Each section has a description of the options and what they do. Only a few lines down, under the commands section, you will see the upgrade type is already set to “default”. Leave it as default if you want all updates (from all available repositories) to be considered. Alternatively, you can change “upgrade_type = default” to “upgrade_type = security”.

Next, you are able to select the level of automation. I want the updates to be downloaded and applied, so I will use “download_updates = yes” and “apply_updates = yes”. Note the description explaining the behavior depending on which “.timer” is being used. More on that later.

If you want to use email to notify you of when and which updates have been downloaded and/or applied, you will need to change the emitter to “emit_via = email”.

Along with that, you will also need to configure the email section. Add the from and to email addresses you wish to use. Followed by, the host server. In my case, I installed postfix on this same server, so I will set “email_host = localhost”.

You should also set the from and to options in the command_email section, as well. You can use the same email addresses you used for the email section above. Save your changes and exit nano (Ctrl+X).

Now, we need edit the timer config, itself-

# nano /usr/lib/systemd/system/dnf-automatic.timer

I wanted to schedule the timer to run every day at 1 AM. I removed the settings under the [Timer] section and replaced it with-

OnCalendar=*-*-* 01:00:00

Save and exit the config file (Ctrl+X). (For more info on systemd timers, I found this site to be helpful- https://www.certdepot.net/rhel7-use-systemd-timers/)

Now that we have configured the the timer’s schedule, we need to enable and start dnf-automatic.timer (this time uses the settings that we configured in the dnf-automatic.conf file above) by running this command-

# systemctl enable dnf-automatic.timer && systemctl start dnf-automatic.timer

If everything has been configured properly, you should get an email the next time that updates are downloaded and applied.

Things to be aware of-

  • You will need to either specify an external email server that you already use, or install and configure an email server on the local system.
  • The server will not reboot itself automatically. You must reboot the server for some updates to be applied.
  • Email notifications will only be sent if/when updates have been applied. If there are no updates, there will be no notifications.

Leave a Reply