原本以為使用 DEBIAN_FRONTEND=noninteractive
參數就可以:
sudo DEBIAN_FRONTEND=noninteractive apt upgrade
後來發現還有個套件叫做 needrestart
,預設會在 apt upgrade 完成後詢問哪一些服務要重新啟動:
which services should be restarted
先檢查一下是否有安裝 needrestart
,有的話可以看到 /etc/needrestart
目錄。
再去修改設定檔 needrestart.conf
:
# Restart mode: (l)ist only, (i)nteractive or (a)utomatically. # # ATTENTION: If needrestart is configured to run in interactive mode but is run # non-interactive (i.e. unattended-upgrades) it will fallback to list only mode. # $nrconf{restart} = 'a';
參考資料: