DNF の自動アップデート / Rocky Linux9.4 on さくらのVPS

アフィリエイト広告を利用しています

このページの内容が役に立ったら X (旧twitter) でフォローして頂けると励みになります
挨拶や報告は無しで大丈夫です

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

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

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

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

環境

実施日2024-05-13
サーバさくらのVPS 2G
OSRocky Linux9.4
cat /etc/redhat-release
Rocky Linux release 9.4 (Blue Onyx)

dnf-automaticのインストール

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

dnf install dnf-automatic

設定の変更

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

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

epel と remi を対象に加える

上記まででは、epel / remi で enable=0 (無効化)していると自動更新の対象になっていません。

enable=0 の epel / remi を対象に加えるには次のようにします。

vi /etc/dnf/automatic.conf

[comands] セクションに次の内容を加えます

extra_args = --enablerepo=epel,remi-safe

手動で更新する場合

dnf --enablerepo=epel update
dnf --enablerepo=remi-safe update

コマンド集

起動する

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