Keeping your system updated is one of the most important steps for maintaining security, stability, and performance. On Rocky Linux 9.6, the dnf-automatic package can periodically check for available updates and either notify administrators, download packages, or install updates automatically.
This guide covers installation, configuration, automatic updates, and a notification-only configuration that uses MOTD without downloading or installing packages.
1. Install dnf-automatic
The dnf-automatic tool is not installed by default. Install it with:
sudo dnf install -y dnf-automatic
2. Configure dnf-automatic
The main configuration file is:
/etc/dnf/automatic.conf
Open it with your preferred text editor:
sudo nano /etc/dnf/automatic.conf
Key options
Upgrade type
The upgrade_type setting controls which updates are detected:
[commands]
upgrade_type = security
Available values include:
-
default— all available updates -
security— only updates associated with security advisories
Download updates
To allow automatic package downloads:
download_updates = yes
To prevent automatic package downloads:
download_updates = no
Apply updates automatically
To install available updates automatically:
apply_updates = yes
To prevent automatic installation:
apply_updates = no
When apply_updates = yes is configured, packages must also be downloaded.
Emitters
The [emitters] section controls how results are reported. Available mechanisms include standard output, email, custom commands, and MOTD.
For example, to report results through MOTD:
[emitters]
emit_via = motd
The MOTD emitter writes the update report to /etc/motd, allowing administrators to see it when logging in through SSH or a local console.
3. Enable Automatic Updates
The generic dnf-automatic.timer follows the behavior configured in /etc/dnf/automatic.conf.
For example, to download and install security updates automatically, configure:
[commands]
upgrade_type = security
download_updates = yes
apply_updates = yes
Then enable and start the timer:
sudo systemctl enable --now dnf-automatic.timer
This causes dnf-automatic to check for and process updates according to the configuration file.
4. Notification Only with MOTD
To notify administrators about available updates without downloading or installing any packages, configure dnf-automatic to use the MOTD emitter.
Edit /etc/dnf/automatic.conf:
sudo nano /etc/dnf/automatic.conf
Use the following settings:
[commands]
upgrade_type = security
download_updates = no
apply_updates = no
[emitters]
emit_via = motd
This configuration:
- Checks repository metadata for available security updates
- Does not download update packages
- Does not install update packages
- Writes the result to
/etc/motd
Enable the notification-only timer:
sudo systemctl enable --now dnf-automatic-notifyonly.timer
The dnf-automatic-notifyonly.timer unit overrides the download and installation behavior and performs notification only. The explicit download_updates = no and apply_updates = no settings are retained in the configuration for clarity and as a safe default when the generic timer is used.
Disable download and installation timers
To ensure that no other dnf-automatic timer downloads or installs packages, disable the generic, download, and installation timers:
sudo systemctl disable --now dnf-automatic.timer
sudo systemctl disable --now dnf-automatic-download.timer
sudo systemctl disable --now dnf-automatic-install.timer
Then enable only the notification timer:
sudo systemctl enable --now dnf-automatic-notifyonly.timer
Verify the enabled timers:
systemctl list-timers --all | grep dnf-automatic
Only dnf-automatic-notifyonly.timer should be enabled for the notification-only configuration.
Check the MOTD output
Run the service manually to test the configuration:
sudo systemctl start dnf-automatic-notifyonly.service
Display the generated MOTD:
cat /etc/motd
The message will also be displayed during the next SSH or console login, provided the system's login configuration displays /etc/motd.
Note: Checking for updates still requires refreshing or reading repository metadata. The notification-only configuration prevents RPM packages from being downloaded; it does not eliminate repository metadata traffic.
5. Other Timer Modes
dnf-automatic provides several systemd timers for different operating modes.
Follow /etc/dnf/automatic.conf
sudo systemctl enable --now dnf-automatic.timer
Notify only
Checks for updates and reports the result without downloading or installing packages:
sudo systemctl enable --now dnf-automatic-notifyonly.timer
Download without installation
Downloads available packages but does not install them:
sudo systemctl enable --now dnf-automatic-download.timer
Download and install
Downloads and installs available updates:
sudo systemctl enable --now dnf-automatic-install.timer
The specialized timer units override the corresponding download and installation settings in /etc/dnf/automatic.conf.
6. Verification and Troubleshooting
Check the notification-only timer:
systemctl status dnf-automatic-notifyonly.timer
Check when it will run next:
systemctl list-timers --all | grep dnf-automatic
Check the service logs:
journalctl -u dnf-automatic-notifyonly.service
Check recent logs for all dnf-automatic units:
journalctl -u 'dnf-automatic*'
Confirm which timers are enabled:
systemctl is-enabled dnf-automatic.timer
systemctl is-enabled dnf-automatic-notifyonly.timer
systemctl is-enabled dnf-automatic-download.timer
systemctl is-enabled dnf-automatic-install.timer
For a notification-only system, the expected result is:
disabled
enabled
disabled
disabled
Conclusion
Rocky Linux 9.6 can use dnf-automatic in several modes:
- Automatic installation for systems that should remain patched without manual intervention
- Automatic download for systems where installation is performed separately
- Notification only for controlled environments where administrators review updates before taking action
For a notification-only configuration with no package downloads, use:
[commands]
upgrade_type = security
download_updates = no
apply_updates = no
[emitters]
emit_via = motd
Enable only:
sudo systemctl enable --now dnf-automatic-notifyonly.timer
This configuration reports available security updates through MOTD while leaving package download and installation under manual control.
dnf-automatic を使用して Rocky Linux 9 を最新の状態に保つ
システムを最新の状態に維持することは、セキュリティ、安定性、およびパフォーマンスを確保するために最も重要な作業の一つです。Rocky Linux 9.6 では、dnf-automatic パッケージを使用することで、利用可能な更新を定期的に確認し、管理者への通知、パッケージのダウンロード、または更新の自動インストールを実行できます。
このガイドでは、インストール、設定、自動更新の構成、およびパッケージのダウンロードやインストールを行わずに MOTD を使用して通知のみを行う構成について説明します。
1. dnf-automatic をインストールする
dnf-automatic はデフォルトではインストールされていません。次のコマンドでインストールします。
sudo dnf install -y dnf-automatic
2. dnf-automatic を設定する
メインの設定ファイルは次の場所にあります。
/etc/dnf/automatic.conf
お好みのテキストエディタで開きます。
sudo nano /etc/dnf/automatic.conf
主な設定項目
更新の種類
upgrade_type は、どの種類の更新を検出するかを指定します。
[commands]
upgrade_type = security
指定できる値は次のとおりです。
-
default— 利用可能なすべての更新 -
security— セキュリティアドバイザリに関連付けられた更新のみ
更新パッケージのダウンロード
パッケージを自動的にダウンロードする場合は、次のように設定します。
download_updates = yes
自動ダウンロードを無効にする場合は、次のように設定します。
download_updates = no
更新の自動適用
利用可能な更新を自動的にインストールする場合は、次のように設定します。
apply_updates = yes
自動インストールを無効にする場合は、次のように設定します。
apply_updates = no
apply_updates = yes を設定する場合は、パッケージのダウンロードも有効になっている必要があります。
Emitters(通知方法)
[emitters] セクションでは、結果の通知方法を指定します。利用できる通知方法には、標準出力、メール、カスタムコマンド、および MOTD があります。
たとえば、MOTD を使用して通知する場合は次のように設定します。
[emitters]
emit_via = motd
MOTD エミッターは更新結果を /etc/motd に書き込み、SSH やローカルコンソールでログインした際に管理者が確認できるようにします。
3. 自動更新を有効にする
汎用の dnf-automatic.timer は、/etc/dnf/automatic.conf に設定された内容に従って動作します。
たとえば、セキュリティ更新を自動的にダウンロードしてインストールする場合は、次のように設定します。
[commands]
upgrade_type = security
download_updates = yes
apply_updates = yes
その後、タイマーを有効化して起動します。
sudo systemctl enable --now dnf-automatic.timer
これにより、dnf-automatic は設定ファイルに従って更新を確認し、必要な処理を実行します。
4. MOTD を使用した通知のみの構成
パッケージをダウンロードまたはインストールせず、利用可能な更新だけを管理者へ通知する場合は、dnf-automatic を MOTD エミッターで構成します。
/etc/dnf/automatic.conf を編集します。
sudo nano /etc/dnf/automatic.conf
次のように設定します。
[commands]
upgrade_type = security
download_updates = no
apply_updates = no
[emitters]
emit_via = motd
この構成では次の動作を行います。
- 利用可能なセキュリティ更新を確認する
- 更新パッケージはダウンロードしない
- 更新パッケージはインストールしない
- 結果を
/etc/motdに書き込む
通知専用タイマーを有効にします。
sudo systemctl enable --now dnf-automatic-notifyonly.timer
dnf-automatic-notifyonly.timer は、ダウンロードおよびインストール動作を上書きし、通知のみを実行します。download_updates = no および apply_updates = no を設定ファイルに明示的に記述しておくことで、設定内容が分かりやすくなり、汎用タイマーを使用した場合でも安全なデフォルトとして機能します。
ダウンロードおよびインストール用タイマーを無効にする
他の dnf-automatic タイマーによってパッケージがダウンロードまたはインストールされないようにするため、汎用タイマー、ダウンロードタイマー、およびインストールタイマーを無効にします。
sudo systemctl disable --now dnf-automatic.timer
sudo systemctl disable --now dnf-automatic-download.timer
sudo systemctl disable --now dnf-automatic-install.timer
その後、通知専用タイマーのみを有効にします。
sudo systemctl enable --now dnf-automatic-notifyonly.timer
有効になっているタイマーを確認します。
systemctl list-timers --all | grep dnf-automatic
通知専用構成では、dnf-automatic-notifyonly.timer のみが有効になっていることを確認してください。
MOTD の出力を確認する
設定をテストするためにサービスを手動で実行します。
sudo systemctl start dnf-automatic-notifyonly.service
生成された MOTD を表示します。
cat /etc/motd
システムのログイン設定で /etc/motd が表示されるようになっていれば、次回 SSH またはローカルコンソールでログインした際にも同じ内容が表示されます。
注: 更新の確認では、リポジトリメタデータの更新または読み込みが必要です。通知専用構成では RPM パッケージのダウンロードは行われませんが、リポジトリメタデータの通信自体は発生します。
5. その他のタイマーモード
dnf-automatic には、用途に応じた複数の systemd タイマーが用意されています。
/etc/dnf/automatic.conf の設定に従う
sudo systemctl enable --now dnf-automatic.timer
通知のみ
更新を確認し、ダウンロードやインストールを行わずに結果だけを通知します。
sudo systemctl enable --now dnf-automatic-notifyonly.timer
ダウンロードのみ
利用可能な更新パッケージをダウンロードしますが、インストールは行いません。
sudo systemctl enable --now dnf-automatic-download.timer
ダウンロードとインストール
更新パッケージをダウンロードし、そのままインストールします。
sudo systemctl enable --now dnf-automatic-install.timer
これらの専用タイマーは、/etc/dnf/automatic.conf に設定されたダウンロードおよびインストールに関する項目を必要に応じて上書きして動作します。
6. 動作確認とトラブルシューティング
通知専用タイマーの状態を確認します。
systemctl status dnf-automatic-notifyonly.timer
次回の実行予定を確認します。
systemctl list-timers --all | grep dnf-automatic
サービスログを確認します。
journalctl -u dnf-automatic-notifyonly.service
dnf-automatic に関連するすべてのログを確認します。
journalctl -u 'dnf-automatic*'
各タイマーが有効かどうかを確認します。
systemctl is-enabled dnf-automatic.timer
systemctl is-enabled dnf-automatic-notifyonly.timer
systemctl is-enabled dnf-automatic-download.timer
systemctl is-enabled dnf-automatic-install.timer
通知専用構成では、期待される結果は次のとおりです。
disabled
enabled
disabled
disabled
まとめ
Rocky Linux 9.6 では、dnf-automatic を次のような用途に応じて利用できます。
- 手動操作なしで常に最新の状態を維持したいシステム向けの自動インストール
- インストールは別途実施し、事前にパッケージだけを取得したい環境向けの自動ダウンロード
- 更新内容を管理者が確認したうえで適用する運用向けの通知のみ
パッケージをダウンロードせず、通知のみを行う構成は次のとおりです。
[commands]
upgrade_type = security
download_updates = no
apply_updates = no
[emitters]
emit_via = motd
有効にするタイマーは次のものだけです。
sudo systemctl enable --now dnf-automatic-notifyonly.timer
この構成では、利用可能なセキュリティ更新が MOTD を通じて通知され、パッケージのダウンロードおよびインストールは手動管理のまま維持されます。
Top comments (0)