如何在Debian 9 Stretch上设置无人值守升级

・3 分钟阅读

使用不同的系统?

运行此命令安装"unattended-upgrades"软件包,以及一个用于标识更改的软件包:


apt -y install unattended-upgrades apt-listchanges

安装之后,编辑无人参与的升级配置:


nano /etc/apt/apt.conf.d/50unattended-upgrades

清空后将下列内容粘贴到此文件中,然后用** **.修改项目,记住删除星号。


APT::Periodic::Update-Package-Lists"1";
APT::Periodic::Download-Upgradeable-Packages"1";
APT::Periodic::AutocleanInterval"7";
APT::Periodic::Unattended-Upgrade"1";
Unattended-Upgrade::Mail"**YOUR_EMAIL_HERE**";

// Automatically upgrade packages from these 
Unattended-Upgrade::Origins-Pattern {
"o=Debian,a=stable";
"o=Debian,a=stable-updates";
"o=Debian,a=proposed-updates";
"origin=Debian,codename=${distro_codename},label=Debian-Security";
};

// You can specify your own packages to NOT automatically upgrade here
Unattended-Upgrade::Package-Blacklist {
//"vim";
//"libc6";
//"libc6-dev";
//"libc6-i686";

};

Unattended-Upgrade::MailOnlyOnError"true";
Unattended-Upgrade::Automatic-Reboot"false";

注意:从文件中删除原始行(ctrl k)

注意:如果希望服务器在必要时重新启动,则可以将Automatic-Reboot设置为true

安装"apticron"以管理APT更新的自动执行:


apt -y install apticron

打开/etc/apticron/apticron.conf并将电子邮件变量设置为你的邮件地址,这样你就可以接收更改列表。


EMAIL="**me@example.com**"
DIFF_ONLY="1"
LISTCHANGES_PROFILE="apticron"
SYSTEM="**HOSTNAME.OF.SERVER**"
NOTIFY_HOLDS="0"
NOTIFY_NO_UPDATES="0"

打开/etc/apt/listchanges.conf以配置APT以保存对数据库的更改:


[apt]
frontend=pager
email_address=**me@example**
confirm=0
save_seen=/var/lib/apt/listchanges.db
which=news

你可以使用调试模式手动运行unattended-upgrade,以查看它是否正常工作:


unattended-upgrade -d

Anne655 profile image