I have been struggling with in various forms, year after year. See here and here. Either I am configuring something wrong (unlikely), or I am using my computer in a bizarre way (I don't see it).
My computer is a laptop:
- Before, I turned it off at night - as a result the
unattended-upgrade
could often not connect to the internet when it wanted to. Result: my computer was left un-upgraded and insecure for months on end. - These days I mostly stay logged in, but the hotspot connection is unavailable at night. So now, the
unattended-upgrade
runs but finds nothing to update, apparently becauseapt update
has not been able to run successfully. Result: my computer is left un-upgraded and insecure for months on end.
How can I ensure the systemd
timer for apt update
does not go weeks and months between runs?
Typical output of /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)
NB: there was a reboot a few hours ago. Not plugged in but was connected to network.
FINAL CONCLUSION. Going with version of the accepted solution below, shifting the apt-daily.timer
to a time when the internet connection is more likely to be available. Thanks for those who helped. The end.