Ubuntu のシステム自動更新を停止する方法

Ubuntu のシステム自動更新を停止する方法

Ubuntu にはシステムの自動更新の仕組みがあります。セキュリティ上の理由から推奨される設定ではあるものの、私の運用環境では自動更新が動いたことによって実行中だった処理が落ちてしまうことがありました。

そこで Ubuntu のシステム自動更新を停止する方法を紹介します。

# パッケージリストの更新(apt update)の自動実行を停止
systemctl disable apt-daily.timer --now

# パッケージのアップグレード(apt upgrade)の自動実行を停止
systemctl disable apt-daily-upgrade.timer --now

# セキュリティアップデートの自動実行を停止
systemctl disable unattended-upgrades.service --now

現在の設定状況は以下で確認します。

systemctl status apt-daily.timer
systemctl status apt-daily-upgrade.timer
systemctl status unattended-upgrades.service

再度、自動更新を有効化したい場合は以下を実行します。

systemctl enable apt-daily.timer --now
systemctl enable apt-daily-upgrade.timer --now
systemctl enable unattended-upgrades.service --now