我一直在以各种形式挣扎,年复一年。见这里和这里。要么我配置错误(不太可能),要么我以一种奇怪的方式使用我的电脑(我没有看到它)。
我的电脑是笔记本电脑:
- 以前,我在晚上关掉了它——结果它
unattended-upgrade
经常无法在需要的时候连接到互联网。结果:我的电脑连续几个月没有升级和不安全。 - 这些天我大部分时间都保持登录状态,但是晚上热点连接不可用。所以现在,
unattended-upgrade
运行了却发现没有更新,显然是因为apt update
一直没能成功运行。结果:我的电脑连续几个月没有升级并且不安全。
如何确保systemd
计时器apt update
在运行之间不会间隔数周和数月?
的典型输出/var/log/unattended-upgrades/unattended-upgrades.log
2022-02-09 06:30:27,331 INFO Starting unattended upgrades script
2022-02-09 06:30:27,334 INFO Allowed origins are: o=Ubuntu,a=focal, o=Ubuntu,a=focal-security, o=UbuntuESMApps,a=focal-apps-security, o=UbuntuESM,a=focal-infra-security, o=UbuntuESM,a=focal-security
2022-02-09 06:30:27,335 INFO Initial blacklist:
2022-02-09 06:30:27,336 INFO Initial whitelist (not strict):
2022-02-09 06:30:40,279 INFO No packages found that can be upgraded unattended and no pending auto-removals
sudo systemctl status apt-daily
:
* apt-daily.service - Daily apt download activities
Loaded: loaded (/lib/systemd/system/apt-daily.service; static; vendor preset: enabled)
Active: inactive (dead)
TriggeredBy: * apt-daily.timer
Condition: start condition failed at Wed 2022-02-09 20:42:17 EET; 4h 17min ago
└─ ConditionACPower=true was not met
Docs: man:apt(8)
Feb 09 20:42:17 tbox systemd[1]: Condition check resulted in Daily apt download activities being skippe>
lines 1-9/9 (END)
sudo systemctl list-timers apt-daily
:
NEXT LEFT LAST PASSED UNIT ACTIVATES>
Thu 2022-02-10 16:15:14 EET 15h left Wed 2022-02-09 20:42:17 EET 4h 22min ago apt-daily.timer apt-daily>
1 timers listed.
Pass --all to see loaded but inactive timers, too.
lines 1-5/5 (END)
注意:几个小时前有重新启动。未插入但已连接到网络。
定论。使用下面接受的解决方案的版本,将其转移apt-daily.timer
到互联网连接更有可能可用的时间。感谢那些帮助过的人。结束。