パッケージの自動更新
dnf-automatic を使用したパッケージの自動更新と必要に応じて再起動をする方法を説明します。
インストール
# dnf install dnf-automatic
設定ファイルのコピー
# cp /usr/share/dnf5/dnf5-plugins/automatic.conf /etc/dnf/dnf5-plugins/automatic.conf
設定ファイルの編集
「/etc/dnf/dnf5-plugins/automatic.conf」
必要に応じてシステムを再起動する設定にしています。
# This configuration file is managed by the dnf5-plugin-automatic package.
# Please do not edit it. To make changes in dnf5 automatic configuration
# edit /etc/dnf/automatic.conf and make your adjustments there.
[commands]
# Whether updates should be applied when they are available, by
# dnf5 automatic.
apply_updates = yes
# Whether updates should be downloaded when they are available, by
# dnf5 automatic.
download_updates = yes
# Maximum time in seconds to wait until the system is on-line and able to
# connect to remote repositories.
# 0 means that network availability detection will be skipped.
network_online_timeout = 60
# Maximum random delay in seconds before downloading (only applied if
# ``--timer`` option was used). Note that, by default, the ``systemd`` timers
# also apply a random delay of up to 1 hour.
random_sleep = 0
# What kind of upgrade to perform:
# default = all available upgrades
# security = only the security upgrades
upgrade_type = default
# When the system should reboot following upgrades:
# never = don't reboot after upgrades
# when-changed = reboot after any changes
# when-needed = reboot when necessary to apply changes
#reboot = never
reboot = when-needed
# The command that is run to trigger a system reboot.
reboot_command = "shutdown -r +5 'Rebooting after applying package updates'"
[emitters]
# Name to use for this system in messages that are emitted. Default is the
# hostname.
# system_name = my-host
# How to send messages. Valid options are stdio, command, command_email,
# email, and motd. Multiple comma separated options can be specified.
# stdio: messages will be sent to stdout; this is useful to have cron send the
# messages.
# command: to send result to a custom command.
# email: dnf5 automatic will send email itself according to the configured
# options.
# motd: /etc/motd.d/dnf5-automatic file will have the messages.
# command_email: then messages will be send via a shell command compatible with
# sendmail.
# If emit_via is left blank, no messages will be sent.
emit_via = stdio
# Whether to emit a message when nothing interesting happened - the operation
# succeeded and no packages were available/installed.
emit_no_updates = no
[command]
# The shell command to execute.
# command_format = "cat"
# The contents of stdin to pass to the command. Variable `body` with the message
# body is usable.
# stdin_format = "{body}"
[command_email]
# The shell command to use to send email. Variables `subject`, `email_from`,
# and `email_to` are available.
# command_format = "mail -Ssendwait -s {subject} -r {email_from} {email_to}"
# The contents of stdin to pass to the command. It is a format string with the
# same arguments as `command_format`.
# stdin_format = "{body}"
# The address to send email messages from.
email_from = root
# List of addresses to send messages to.
email_to = root
[email]
# The address to send email messages from.
email_from = root
# List of addresses to send messages to.
email_to = root
# Name of the host to connect to to send email messages.
email_host = localhost
# Port number to connect to at the email host.
email_port = 25
# Use TLS or STARTTLS to connect to the email host.
# Available values are "no", "yes", and "starttls"
email_tls = no
# Credentials to use for SMTP server authentication are taken from .netrc file
[base]
# This section overrides config values from the dnf.conf (see man dnf.conf for
# available options).
タイマーの設定
# systemctl enable --now dnf5-automatic.timer
タイマーの確認
# systemctl list-timers
NEXT LEFT LAST PASSED UNIT ACTIVATES
Thu 2025-07-17 16:05:30 JST 4h 32min Thu 2025-07-17 04:55:11 JST - certbot-renew.timer certbot-renew.service
Fri 2025-07-18 00:00:00 JST 12h Thu 2025-07-17 00:00:06 JST - unbound-anchor.timer unbound-anchor.service
Fri 2025-07-18 00:09:16 JST 12h Thu 2025-07-17 00:05:33 JST - logrotate.timer logrotate.service
Fri 2025-07-18 00:44:19 JST 13h Thu 2025-07-17 00:38:48 JST - plocate-updatedb.timer plocate-updatedb.service
Fri 2025-07-18 06:43:03 JST 19h - - dnf5-automatic.timer dnf5-automatic.service
Fri 2025-07-18 10:59:02 JST 23h Thu 2025-07-17 10:59:02 JST 33min ago systemd-tmpfiles-clean.timer systemd-tmpfiles-clean.service
Sun 2025-07-20 01:00:00 JST 2 days Sun 2025-07-13 01:00:02 JST - raid-check.timer raid-check.service
Mon 2025-07-21 00:02:34 JST 3 days Mon 2025-07-14 01:09:27 JST - fstrim.timer fstrim.service
8 timers listed.
Pass --all to see loaded but inactive timers, too.