安装
sudo apt-get install unattended-upgrades
sudo dpkg-reconfigure -plow unattended-upgrades
执行后进入交互界面,选择 Yes->OK 就可以了。
配置更新内容
默认情况下只安装安全相关的更新,不过你也可以根据你的需要修改下面路径文件,以决定要自动安装哪些更新:
/etc/apt/apt.conf.d/50unattended-upgrades
Unattended-Upgrade::Allowed-Origins {
"${distro_id}:${distro_codename}";
"${distro_id}:${distro_codename}-security";
// "${distro_id}:${distro_codename}-updates";
// "${distro_id}:${distro_codename}-proposed";
// "${distro_id}:${distro_codename}-backports";
};
// 更新后自动重启设备
Unattended-Upgrade::Automatic-Reboot "true";
Unattended-Upgrade::Automatic-Reboot-Time "04:00";
设置更新频率
默认情况下更新频率是一天一次,可以在/etc/apt/apt.conf.d/20auto-upgrades
文件里修改这个设置,文件里的 1 表示一天,换成你想设置的天数即可。
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";
From: http://lazybios.com/2017/01/automatic-security-updates-for-ubuntu/