尝试使用以下方法在私有 Debian 存储库上实现“自动更新”unattended-upgrades
尝试检查1755716建议的解决方案没有成功
问题是,除非apt update
事先运行,否则不会获取和安装新版本
它确实可以手动运行 -apt update && apt update X
并且新版本已成功安装
尝试手动运行unattended-upgrades
命令 -> 显示没有可用更新
sudo unattended-upgrades -v
Starting unattended upgrades script
Allowed origins are: o=Artifactory,a=bionic, o=Ubuntu,a=jammy, o=Ubuntu,a=jammy-security, o=UbuntuESMApps,a=jammy-apps-security, o=UbuntuESM,a=jammy-infra-security, o=Ubuntu,a=jammy-updates
Initial blacklist:
Initial whitelist (not strict):
No packages found that can be upgraded unattended and no pending auto-removals
我的配置/设置
/etc/apt/apt.conf.d/50unattended-upgrades
Unattended-Upgrade::Allowed-Origins {
"Artifactory bionic"; // My custom repository
"${distro_id}:${distro_codename}";
"${distro_id}:${distro_codename}-security";
"${distro_id}ESMApps:${distro_codename}-apps-security";
"${distro_id}ESM:${distro_codename}-infra-security";
"${distro_id}:${distro_codename}-updates";
};
Unattended-Upgrade::Package-Blacklist {
};
Unattended-Upgrade::DevRelease "false";
Unattended-Upgrade::Remove-Unused-Kernel-Packages "true";
Unattended-Upgrade::Remove-Unused-Dependencies "true";
Unattended-Upgrade::Automatic-Reboot "true";
/etc/apt/apt.conf.d/10periodic
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Download-Upgradeable-Packages "0";
APT::Periodic::AutocleanInterval "0";
APT::Periodic::Unattended-Upgrade "1";
将我的仓库添加到/etc/apt/sources.list
deb [trusted=yes] https://x:[email protected]/artifactory/bodel bionic main
systemctl list-timers | grep apt
Sun 2024-01-07 21:46:23 UTC 9h left Thu 2024-01-04 17:25:55 UTC 2 days ago apt-daily.timer apt-daily.service
Mon 2024-01-08 06:57:49 UTC 18h left Sun 2024-01-07 10:36:13 UTC 2h 9min ago apt-daily-upgrade.timer apt-daily-upgrade.service
答案1
您的输出没有任何问题。一切看起来都很好,包括您的 Artifactory 源。
当你unattended-upgrade
手动运行时,它是不是正在运行apt update
。因此,您的软件包数据库可能比您预期的要旧,或者您可能会在升级列表中看到与预期不同的软件包。
通过使用 apt 您知道更新需要执行两个操作:
- 更新可用软件包的数据库(
apt update
和apt-daily.service
) - 在更新的数据库中搜索升级的软件包、下载并安装(
apt upgrade
和apt-daily-upgrade.service
和unattended-upgrade
)
这里的关键是该unattended-upgrade
命令不是执行两项操作。它只运行第二个(升级)。它确实不是首先更新数据库。
对于无人值守升级的正常使用,这足以让您的 Ubuntu 系统包在发布后的 24-48 小时内完全自动保持更新。