AlmaLinux9.3で DNF の自動アップデートを設定する

さくらのVPSにAlmaLinux9.3をインストールした覚書です。

今回は、サーバのアップデートを自動的に行う dnf-automatic の設定を行っていきたいと思います。

CentOS7 までは yum-cron を使っていたと思います。
CentOS8 からは、yum が dnf になり、yum-cron ではなく dnf-automatic を使っていきます。

なお本番環境で利用される場合はここにある内容だけを鵜呑みにせずセキュリティ専門家に相談されることをお勧めします。

環境

実施日2024-04-23
サーバさくらのVPS 2G
OSAlmaLinux9.3
cat /etc/redhat-release
AlmaLinux release 9.3 (Shamrock Pampas Cat)

dnf-automaticのインストール

dnfからインストールします。

dnf install dnf-automatic

設定の変更

vi /etc/dnf/automatic.conf
# アップデートの種類
# default すべてのパッケージ
# security セキュリティ関係のみ
upgrade_type = default

# アップデート適用のタイミング
# yes 即時、自動更新したいならこちら
# no ダウンロードのみ
apply_updates = yes

コマンド集

起動する

systemctl start dnf-automatic.timer

再起動する

systemctl restart dnf-automatic.timer

停止する

systemctl stop dnf-automatic.timer

自動起動に登録

systemctl enable dnf-automatic.timer

自動起動の状態を確認する

systemctl is-enabled dnf-automatic.timer