ServerHandbook live check: run log ------------------------------------------------------------------------------ Check scripts/live/checks/unattended-upgrades-ubuntu-24-04.mjs (sha256 7e6958c225bb5aa1b2fa13653f3de2f6748803ef406d7c5cde624a50d8360a06) Ran at 2026-11-11T18:47:33Z (743 s) Result PASS, all 35 claims held Tested on System Ubuntu 24.04.5 LTS Kernel 6.8.0-149-generic Package unattended-upgrades 2.9.1+nmu4ubuntu1 Package apt 2.8.4ubuntu0.1 Package linux-image-virtual 6.8.0-149.149 Setup A fresh Ubuntu 24.04 server from Ubuntu’s cloud image, with the updates published since the image was built still waiting, reached over SSH as a sudo user. Every version above was read from the server at run time. Passwords used on the throwaway test server are shown as [password]. How we test: https://serverhandbook.com/how-we-test ------------------------------------------------------------------------------ Claims (35), each with what the run saw ------------------------------------------------------------------------------ 1. ok a bare Ubuntu 24.04 server box (web-server) starts 2. ok unattended-upgrades is installed on a fresh server | unattended-upgrades 2.9.1+nmu4ubuntu1 installed 3. ok 20auto-upgrades already turns on the daily list update and the daily upgrade | APT::Periodic::Update-Package-Lists "1"; | APT::Periodic::Unattended-Upgrade "1"; 4. ok two timers drive it: apt-daily (lists) and apt-daily-upgrade (install) | NEXT LEFT LAST PASSED UNIT ACTIVATES | Thu 2026-11-12 06:49:41 UTC 12h - - apt-daily-upgrade.timer apt-daily-upgrade.service | Thu 2026-11-12 15:06:18 UTC 20h - - apt-daily.timer apt-daily.service | | 2 timers listed. | Pass --all to see loaded but inactive timers, too. 5. ok the install timer runs at 6:00 plus up to 60 minutes at random, and catches up after downtime | # /usr/lib/systemd/system/apt-daily-upgrade.timer | [Unit] | Description=Daily apt upgrade and clean activities | After=apt-daily.timer | | [Timer] | OnCalendar=*-*-* 6:00 | RandomizedDelaySec=60m | Persistent=true | | [Install] | WantedBy=timers.target 6. ok the server clock is UTC, so 6:00 means 6:00 UTC | Timezone=Etc/UTC 7. ok it takes packages from the release and -security pockets only (and Ubuntu Pro ESM) | Unattended-Upgrade::Allowed-Origins ""; | Unattended-Upgrade::Allowed-Origins:: "${distro_id}:${distro_codename}"; | Unattended-Upgrade::Allowed-Origins:: "${distro_id}:${distro_codename}-security"; | Unattended-Upgrade::Allowed-Origins:: "${distro_id}ESMApps:${distro_codename}-apps-security"; | Unattended-Upgrade::Allowed-Origins:: "${distro_id}ESM:${distro_codename}-infra-security"; 8. ok a new server has security updates waiting | 24 9. ok the newer kernel is waiting too, but in noble-updates only (not -security) | linux-image-virtual/noble-updates 6.8.0-149.149 amd64 [upgradable from: 6.8.0-147.147] 10. ok --dry-run -v lists what the next run will install, without installing | Packages that will be upgraded: apt apt-utils bind9-dnsutils bind9-host bind9-libs ca-certificates distro-info-data git git-man libapt-pkg6.0t64 libbrotli1 liblzma5 libmspack0t64 libnss3 libpcre2-8-0 libperl5.38t64 perl perl-base perl-modules-5.38 python3-jwt python3-pyasn1 python3-twisted xz-utils zlib1g 11. ok (the drop-in is exactly as the article shows it) | [Timer] | OnCalendar= | OnCalendar=*-*-* 03:00 | RandomizedDelaySec=15m 12. ok the next run is now between 03:00 and 03:15 | NEXT LEFT LAST PASSED UNIT ACTIVATES | Thu 2026-11-12 03:01:05 UTC 8h - - apt-daily-upgrade.timer apt-daily-upgrade.service | | 1 timers listed. | Pass --all to see loaded but inactive timers, too. 13. ok (the timer fired on its own at 18:53 UTC and its run finished) | 0= | > → 450538572 | > inactive 14. ok the journal shows the timer’s service ran and finished: "Finished apt-daily-upgrade.service" | Nov 11 18:55:06 web-server systemd[1]: apt-daily-upgrade.service: Deactivated successfully. | Nov 11 18:55:06 web-server systemd[1]: Finished apt-daily-upgrade.service - Daily apt upgrade and clean activities. | Nov 11 18:55:06 web-server systemd[1]: apt-daily-upgrade.service: Consumed 1min 26.502s CPU time, 644.4M memory peak, 0B memory swap peak. 15. ok its log lists the packages it upgraded and ends "All upgrades installed" | 2026-11-11 18:53:07,130 INFO Initial whitelist (not strict): | 2026-11-11 18:53:15,671 INFO Packages that will be upgraded: apt apt-utils bind9-dnsutils bind9-host bind9-libs ca-certificates distro-info-data git git-man libapt-pkg6.0t64 libbrotli1 liblzma5 libmspack0t64 libnss3 libpcre2-8-0 libperl5.38t64 perl perl-base perl-modules-5.38 python3-jwt python3-pyasn1 python3-twisted xz-utils zlib1g | 2026-11-11 18:53:15,671 INFO Writing dpkg log to /var/log/unattended-upgrades/unattended-upgrades-dpkg.log | 2026-11-11 18:55:05,594 INFO All upgrades installed 16. ok the log folder is not readable without sudo | ls: cannot open directory '/var/log/unattended-upgrades/': Permission denied 17. ok no security updates are left | 0 18. ok the kernel from noble-updates was left alone | linux-image-virtual/noble-updates 6.8.0-149.149 amd64 [upgradable from: 6.8.0-147.147] 19. ok nothing it installed needs a reboot (no /var/run/reboot-required) | ls: cannot access '/var/run/reboot-required': No such file or directory 20. ok starting the service again the same day does nothing: the log gets no new line | 18 → 18 21. ok …because /var/lib/apt/periodic/upgrade-stamp is dated today | -rw-r--r-- 1 root root 0 2026-11-11 /var/lib/apt/periodic/upgrade-stamp 22. ok (the 52unattended-upgrades-local file is exactly as the article shows it) | Unattended-Upgrade::Allowed-Origins { | "${distro_id}:${distro_codename}-updates"; | }; | Unattended-Upgrade::Automatic-Reboot "true"; | Unattended-Upgrade::Automatic-Reboot-Time "02:00"; 23. ok the new file ADDS -updates to the list; the default origins stay | Unattended-Upgrade::Allowed-Origins ""; | Unattended-Upgrade::Allowed-Origins:: "${distro_id}:${distro_codename}"; | Unattended-Upgrade::Allowed-Origins:: "${distro_id}:${distro_codename}-security"; | Unattended-Upgrade::Allowed-Origins:: "${distro_id}ESMApps:${distro_codename}-apps-security"; | Unattended-Upgrade::Allowed-Origins:: "${distro_id}ESM:${distro_codename}-infra-security"; | Unattended-Upgrade::Allowed-Origins:: "${distro_id}:${distro_codename}-updates"; 24. ok a run now installs the kernel from -updates | Packages that will be upgraded: cloud-init distro-info gir1.2-glib-2.0 libglib2.0-0t64 libglib2.0-bin libglib2.0-data libsqlite3-0 linux-headers-generic linux-headers-virtual linux-image-virtual linux-libc-dev linux-tools-common linux-virtual python3-distro-info snapd tmux ubuntu-pro-client ubuntu-pro-client-l10n | All upgrades installed | Found /var/run/reboot-required, rebooting | Shutdown msg: b"Reboot scheduled for Thu 2026-11-12 02:00:00 UTC, use 'shutdown -c' to cancel." 25. ok …finds /var/run/reboot-required and schedules the reboot for 02:00 | Packages that will be upgraded: cloud-init distro-info gir1.2-glib-2.0 libglib2.0-0t64 libglib2.0-bin libglib2.0-data libsqlite3-0 linux-headers-generic linux-headers-virtual linux-image-virtual linux-libc-dev linux-tools-common linux-virtual python3-distro-info snapd tmux ubuntu-pro-client ubuntu-pro-client-l10n | All upgrades installed | Found /var/run/reboot-required, rebooting | Shutdown msg: b"Reboot scheduled for Thu 2026-11-12 02:00:00 UTC, use 'shutdown -c' to cancel." 26. ok /var/run/reboot-required.pkgs names the new kernel | linux-image-6.8.0-149-generic | linux-base 27. ok shutdown --show confirms the reboot waiting for 02:00 UTC | Reboot scheduled for Thu 2026-11-12 02:00:00 UTC, use 'shutdown -c' to cancel. 28. ok until the reboot the server still runs the old kernel | 6.8.0-147-generic (new: 6.8.0-149-generic) 29. ok the server comes back after the reboot | 18 30. ok after the reboot it runs the new kernel | 6.8.0-149-generic 31. ok and /var/run/reboot-required is gone | ls: cannot access '/var/run/reboot-required': No such file or directory 32. ok the 03:00 time survives the reboot | NEXT LEFT LAST PASSED UNIT ACTIVATES | Thu 2026-11-12 03:07:37 UTC 8h Wed 2026-11-11 18:53:06 UTC - apt-daily-upgrade.timer apt-daily-upgrade.service | | 1 timers listed. | Pass --all to see loaded but inactive timers, too. 33. ok (tested on) the box reports its OS, kernel and the version of 3 package(s) | PRETTY_NAME="Ubuntu 24.04.5 LTS" | VIRT=none | KERNEL=6.8.0-149-generic | PKG apt 2.8.4ubuntu0.1 | PKG linux-image-virtual 6.8.0-149.149 | PKG unattended-upgrades 2.9.1+nmu4ubuntu1 34. ok Unattended-Upgrade "0" turns the daily install off | APT::Periodic::Unattended-Upgrade "0"; 35. ok (with "0" the timer’s service runs but does not upgrade: no new log line, even with no stamp) | 27 → 27 ------------------------------------------------------------------------------ Commands and what they printed (32) ------------------------------------------------------------------------------ $ dpkg-query -W -f='${Package} ${Version} ${db:Status-Status}\n' unattended-upgrades unattended-upgrades 2.9.1+nmu4ubuntu1 installed $ cat /etc/apt/apt.conf.d/20auto-upgrades APT::Periodic::Update-Package-Lists "1"; APT::Periodic::Unattended-Upgrade "1"; $ systemctl list-timers apt-daily.timer apt-daily-upgrade.timer --no-pager NEXT LEFT LAST PASSED UNIT ACTIVATES Thu 2026-11-12 06:49:41 UTC 12h - - apt-daily-upgrade.timer apt-daily-upgrade.service Thu 2026-11-12 15:06:18 UTC 20h - - apt-daily.timer apt-daily.service 2 timers listed. Pass --all to see loaded but inactive timers, too. $ systemctl cat apt-daily-upgrade.timer --no-pager # /usr/lib/systemd/system/apt-daily-upgrade.timer [Unit] Description=Daily apt upgrade and clean activities After=apt-daily.timer [Timer] OnCalendar=*-*-* 6:00 RandomizedDelaySec=60m Persistent=true [Install] WantedBy=timers.target $ timedatectl show -p Timezone Timezone=Etc/UTC $ apt-config dump Unattended-Upgrade::Allowed-Origins Unattended-Upgrade::Allowed-Origins ""; Unattended-Upgrade::Allowed-Origins:: "${distro_id}:${distro_codename}"; Unattended-Upgrade::Allowed-Origins:: "${distro_id}:${distro_codename}-security"; Unattended-Upgrade::Allowed-Origins:: "${distro_id}ESMApps:${distro_codename}-apps-security"; Unattended-Upgrade::Allowed-Origins:: "${distro_id}ESM:${distro_codename}-infra-security"; $ sudo apt update Get:1 http://security.ubuntu.com/ubuntu noble-security InRelease [126 kB] Hit:2 http://archive.ubuntu.com/ubuntu noble InRelease Get:3 http://archive.ubuntu.com/ubuntu noble-updates InRelease [126 kB] Get:4 http://security.ubuntu.com/ubuntu noble-security/main amd64 Packages [1160 kB] Get:5 http://archive.ubuntu.com/ubuntu noble-backports InRelease [126 kB] Get:6 http://security.ubuntu.com/ubuntu noble-security/main Translation-en [234 kB] Get:7 http://security.ubuntu.com/ubuntu noble-security/main amd64 Components [46.4 kB] Get:8 http://security.ubuntu.com/ubuntu noble-security/universe amd64 Packages [1228 kB] Get:9 http://archive.ubuntu.com/ubuntu noble/universe amd64 Packages [15.0 MB] Get:10 http://security.ubuntu.com/ubuntu noble-security/universe Translation-en [248 kB] Get:11 http://security.ubuntu.com/ubuntu noble-security/universe amd64 Components [76.3 kB] Get:12 http://security.ubuntu.com/ubuntu noble-security/universe amd64 c-n-f Metadata [24.2 kB] Get:13 http://security.ubuntu.com/ubuntu noble-security/restricted amd64 Packages [1729 kB] Get:14 http://security.ubuntu.com/ubuntu noble-security/restricted Translation-en [396 kB] Get:15 http://security.ubuntu.com/ubuntu noble-security/multiverse amd64 Packages [45.4 kB] Get:16 http://security.ubuntu.com/ubuntu noble-security/multiverse Translation-en [12.4 kB] Get:17 http://security.ubuntu.com/ubuntu noble-security/multiverse amd64 Components [208 B] Get:18 http://security.ubuntu.com/ubuntu noble-security/multiverse amd64 c-n-f Metadata [468 B] Get:19 http://archive.ubuntu.com/ubuntu noble/universe Translation-en [5982 kB] Get:20 http://archive.ubuntu.com/ubuntu noble/universe amd64 Components [3871 kB] Get:21 http://archive.ubuntu.com/ubuntu noble/universe amd64 c-n-f Metadata [301 kB] Get:22 http://archive.ubuntu.com/ubuntu noble/multiverse amd64 Packages [269 kB] Get:23 http://archive.ubuntu.com/ubuntu noble/multiverse Translation-en [118 kB] Get:24 http://archive.ubuntu.com/ubuntu noble/multiverse amd64 Components [35.0 kB] Get:25 http://archive.ubuntu.com/ubuntu noble/multiverse amd64 c-n-f Metadata [8328 B] Get:26 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 Packages [1444 kB] Get:27 http://archive.ubuntu.com/ubuntu noble-updates/main Translation-en [315 kB] Get:28 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 Components [181 kB] Get:29 http://archive.ubuntu.com/ubuntu noble-updates/universe amd64 Packages [1711 kB] Get:30 http://archive.ubuntu.com/ubuntu noble-updates/universe Translation-en [344 kB] Get:31 http://archive.ubuntu.com/ubuntu noble-updates/universe amd64 Components [388 kB] Get:32 http://archive.ubuntu.com/ubuntu noble-updates/universe amd64 c-n-f Metadata [34.9 kB] Get:33 http://archive.ubuntu.com/ubuntu noble-updates/restricted amd64 Packages [1879 kB] Get:34 http://archive.ubuntu.com/ubuntu noble-updates/restricted Translation-en [429 kB] Get:35 http://archive.ubuntu.com/ubuntu noble-updates/multiverse amd64 Packages [50.7 kB] Get:36 http://archive.ubuntu.com/ubuntu noble-updates/multiverse Translation-en [14.3 kB] Get:37 http://archive.ubuntu.com/ubuntu noble-updates/multiverse amd64 Components [940 B] Get:38 http://archive.ubuntu.com/ubuntu noble-updates/multiverse amd64 c-n-f Metadata [656 B] Get:39 http://archive.ubuntu.com/ubuntu noble-backports/main amd64 Packages [40.6 kB] Get:40 http://archive.ubuntu.com/ubuntu noble-backports/main Translation-en [9172 B] Get:41 http://archive.ubuntu.com/ubuntu noble-backports/main amd64 Components [5744 B] Get:42 http://archive.ubuntu.com/ubuntu noble-backports/main amd64 c-n-f Metadata [368 B] Get:43 http://archive.ubuntu.com/ubuntu noble-backports/universe amd64 Packages [31.0 kB] Get:44 http://archive.ubuntu.com/ubuntu noble-backports/universe Translation-en [18.6 kB] Get:45 http://archive.ubuntu.com/ubuntu noble-backports/universe amd64 Components [12.6 kB] Get:46 http://archive.ubuntu.com/ubuntu noble-backports/universe amd64 c-n-f Metadata [1588 B] Get:47 http://archive.ubuntu.com/ubuntu noble-backports/restricted amd64 Components [212 B] Get:48 http://archive.ubuntu.com/ubuntu noble-backports/restricted amd64 c-n-f Metadata [116 B] Get:49 http://archive.ubuntu.com/ubuntu noble-backports/multiverse amd64 Packages [748 B] Get:50 http://archive.ubuntu.com/ubuntu noble-backports/multiverse Translation-en [340 B] Get:51 http://archive.ubuntu.com/ubuntu noble-backports/multiverse amd64 Components [212 B] Get:52 http://archive.ubuntu.com/ubuntu noble-backports/multiverse amd64 c-n-f Metadata [116 B] Fetched 38.1 MB in 1min 13s (521 kB/s) Reading package lists... Done Building dependency tree... Done Reading state information... Done 42 packages can be upgraded. Run 'apt list --upgradable' to see them. $ apt list --upgradable 2>/dev/null | grep -c security 24 $ apt list --upgradable 2>/dev/null | grep linux-image linux-image-virtual/noble-updates 6.8.0-149.149 amd64 [upgradable from: 6.8.0-147.147] $ sudo unattended-upgrade --dry-run -v 2>&1 | grep "Packages that will be upgraded" Packages that will be upgraded: apt apt-utils bind9-dnsutils bind9-host bind9-libs ca-certificates distro-info-data git git-man libapt-pkg6.0t64 libbrotli1 liblzma5 libmspack0t64 libnss3 libpcre2-8-0 libperl5.38t64 perl perl-base perl-modules-5.38 python3-jwt python3-pyasn1 python3-twisted xz-utils zlib1g $ cat /etc/systemd/system/apt-daily-upgrade.timer.d/override.conf [Timer] OnCalendar= OnCalendar=*-*-* 03:00 RandomizedDelaySec=15m $ sudo systemctl daemon-reload $ systemctl list-timers apt-daily-upgrade.timer --no-pager NEXT LEFT LAST PASSED UNIT ACTIVATES Thu 2026-11-12 03:01:05 UTC 8h - - apt-daily-upgrade.timer apt-daily-upgrade.service 1 timers listed. Pass --all to see loaded but inactive timers, too. $ sudo journalctl -u apt-daily-upgrade.service --no-pager | tail -n 3 Nov 11 18:55:06 web-server systemd[1]: apt-daily-upgrade.service: Deactivated successfully. Nov 11 18:55:06 web-server systemd[1]: Finished apt-daily-upgrade.service - Daily apt upgrade and clean activities. Nov 11 18:55:06 web-server systemd[1]: apt-daily-upgrade.service: Consumed 1min 26.502s CPU time, 644.4M memory peak, 0B memory swap peak. $ sudo tail -n 4 /var/log/unattended-upgrades/unattended-upgrades.log 2026-11-11 18:53:07,130 INFO Initial whitelist (not strict): 2026-11-11 18:53:15,671 INFO Packages that will be upgraded: apt apt-utils bind9-dnsutils bind9-host bind9-libs ca-certificates distro-info-data git git-man libapt-pkg6.0t64 libbrotli1 liblzma5 libmspack0t64 libnss3 libpcre2-8-0 libperl5.38t64 perl perl-base perl-modules-5.38 python3-jwt python3-pyasn1 python3-twisted xz-utils zlib1g 2026-11-11 18:53:15,671 INFO Writing dpkg log to /var/log/unattended-upgrades/unattended-upgrades-dpkg.log 2026-11-11 18:55:05,594 INFO All upgrades installed $ ls /var/log/unattended-upgrades/ ls: cannot open directory '/var/log/unattended-upgrades/': Permission denied $ apt list --upgradable 2>/dev/null | grep -c security 0 $ apt list --upgradable 2>/dev/null | grep linux-image linux-image-virtual/noble-updates 6.8.0-149.149 amd64 [upgradable from: 6.8.0-147.147] $ ls /var/run/reboot-required ls: cannot access '/var/run/reboot-required': No such file or directory $ sudo systemctl start apt-daily-upgrade.service $ ls -l --time-style=+%F /var/lib/apt/periodic/upgrade-stamp -rw-r--r-- 1 root root 0 2026-11-11 /var/lib/apt/periodic/upgrade-stamp $ cat /etc/apt/apt.conf.d/52unattended-upgrades-local Unattended-Upgrade::Allowed-Origins { "${distro_id}:${distro_codename}-updates"; }; Unattended-Upgrade::Automatic-Reboot "true"; Unattended-Upgrade::Automatic-Reboot-Time "02:00"; $ apt-config dump Unattended-Upgrade::Allowed-Origins Unattended-Upgrade::Allowed-Origins ""; Unattended-Upgrade::Allowed-Origins:: "${distro_id}:${distro_codename}"; Unattended-Upgrade::Allowed-Origins:: "${distro_id}:${distro_codename}-security"; Unattended-Upgrade::Allowed-Origins:: "${distro_id}ESMApps:${distro_codename}-apps-security"; Unattended-Upgrade::Allowed-Origins:: "${distro_id}ESM:${distro_codename}-infra-security"; Unattended-Upgrade::Allowed-Origins:: "${distro_id}:${distro_codename}-updates"; $ sudo unattended-upgrade -v 2>&1 | grep -E "^(Packages that will be upgraded|All upgrades installed|Found /var/run/reboot-required|Shutdown msg)" Packages that will be upgraded: cloud-init distro-info gir1.2-glib-2.0 libglib2.0-0t64 libglib2.0-bin libglib2.0-data libsqlite3-0 linux-headers-generic linux-headers-virtual linux-image-virtual linux-libc-dev linux-tools-common linux-virtual python3-distro-info snapd tmux ubuntu-pro-client ubuntu-pro-client-l10n All upgrades installed Found /var/run/reboot-required, rebooting Shutdown msg: b"Reboot scheduled for Thu 2026-11-12 02:00:00 UTC, use 'shutdown -c' to cancel." $ cat /var/run/reboot-required.pkgs linux-image-6.8.0-149-generic linux-base $ shutdown --show Reboot scheduled for Thu 2026-11-12 02:00:00 UTC, use 'shutdown -c' to cancel. $ uname -r 6.8.0-147-generic $ sudo reboot $ uname -r 6.8.0-149-generic $ ls /var/run/reboot-required ls: cannot access '/var/run/reboot-required': No such file or directory $ systemctl list-timers apt-daily-upgrade.timer --no-pager NEXT LEFT LAST PASSED UNIT ACTIVATES Thu 2026-11-12 03:07:37 UTC 8h Wed 2026-11-11 18:53:06 UTC - apt-daily-upgrade.timer apt-daily-upgrade.service 1 timers listed. Pass --all to see loaded but inactive timers, too. $ apt-config dump APT::Periodic::Unattended-Upgrade APT::Periodic::Unattended-Upgrade "0"; ------------------------------------------------------------------------------ The check's source (scripts/live/checks/unattended-upgrades-ubuntu-24-04.mjs) As it ran. ------------------------------------------------------------------------------ /** * KB: Automatic security updates on Ubuntu 24.04 (unattended-upgrades): check it is on, pick the time, prove it ran, * add regular updates and an automatic reboot, undo. * * The server is a fresh VM box from Ubuntu's cloud image, reached as the sudo user `deploy`. Its packages are as old as * the image, so real security updates are waiting, and the newer kernel sits in noble-updates: this is what a new VPS * looks like. The timer is moved to a time two minutes ahead (a hidden step, then put back) so the run is the TIMER's * own run, not one we started by hand. Every claim below is one the article makes. */ import { rebootBox } from '../box.mjs' import { bareBox, reportBox } from '../lib.mjs' export const meta = {} const sleep = (ms) => Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms) const LOG = '/var/log/unattended-upgrades/unattended-upgrades.log' const DROPIN = '/etc/systemd/system/apt-daily-upgrade.timer.d/override.conf' const check = (ctx) => bareBox(ctx, async ({ sudoUser }) => { const { run, L } = sudoUser() L('sudo true') // a reader has used sudo before (earlier articles), so Ubuntu's first-sudo hint is not on their screen // ── step 1: it is already on ───────────────────────────────────────────────────────────── const pkg = run(`dpkg-query -W -f='\${Package} \${Version} \${db:Status-Status}\\n' unattended-upgrades`, { id: 'installed' }) ctx.check('unattended-upgrades is installed on a fresh server', /^unattended-upgrades \S+ installed$/.test(pkg.out), pkg.out) const auto = run('cat /etc/apt/apt.conf.d/20auto-upgrades', { id: '20auto' }) ctx.check('20auto-upgrades already turns on the daily list update and the daily upgrade', /APT::Periodic::Update-Package-Lists "1";/.test(auto.out) && /APT::Periodic::Unattended-Upgrade "1";/.test(auto.out), auto.out) const timers = run('systemctl list-timers apt-daily.timer apt-daily-upgrade.timer --no-pager', { id: 'timers' }) ctx.check('two timers drive it: apt-daily (lists) and apt-daily-upgrade (install)', /apt-daily\.timer/.test(timers.out) && /apt-daily-upgrade\.timer/.test(timers.out) && /2 timers listed/.test(timers.out), timers.out) const unit = run('systemctl cat apt-daily-upgrade.timer --no-pager', { id: 'timer-unit' }) ctx.check('the install timer runs at 6:00 plus up to 60 minutes at random, and catches up after downtime', /OnCalendar=\*-\*-\* 6:00/.test(unit.out) && /RandomizedDelaySec=60m/.test(unit.out) && /Persistent=true/.test(unit.out), unit.out) const tz = run('timedatectl show -p Timezone', { id: 'timezone' }) ctx.check('the server clock is UTC, so 6:00 means 6:00 UTC', tz.out === 'Timezone=Etc/UTC', tz.out) // ── step 2: what it installs ───────────────────────────────────────────────────────────── const origins = run(`apt-config dump Unattended-Upgrade::Allowed-Origins`, { id: 'origins' }) ctx.check('it takes packages from the release and -security pockets only (and Ubuntu Pro ESM)', /-security";/.test(origins.out) && !/-updates";/.test(origins.out), origins.out) run('sudo apt update', { id: 'apt-update', timeout: 600000 }) const up = run('apt list --upgradable 2>/dev/null | grep -c security', { show: 'apt list --upgradable 2>/dev/null | grep -c security', id: 'count-security' }) const nSec = Number(up.out.split('\n').pop()) ctx.check('a new server has security updates waiting', nSec > 0, up.out) const kern = run('apt list --upgradable 2>/dev/null | grep linux-image', { id: 'kernel-pending' }) ctx.check('the newer kernel is waiting too, but in noble-updates only (not -security)', /linux-image-virtual\/noble-updates /.test(kern.out) && !/noble-security/.test(kern.out), kern.out) const dry = run('sudo unattended-upgrade --dry-run -v 2>&1 | grep "Packages that will be upgraded"', { id: 'dry-run', timeout: 900000 }) ctx.check('--dry-run -v lists what the next run will install, without installing', /Packages that will be upgraded: /.test(dry.out) && !/linux-image/.test(dry.out), dry.out) // ── step 3: pick the time ──────────────────────────────────────────────────────────────── L(`sudo mkdir -p /etc/systemd/system/apt-daily-upgrade.timer.d`) L(`printf '%s\\n' '[Timer]' 'OnCalendar=' 'OnCalendar=*-*-* 03:00' 'RandomizedDelaySec=15m' | sudo tee ${DROPIN} >/dev/null`) const drop = run(`cat ${DROPIN}`, { id: 'dropin' }) ctx.check('(the drop-in is exactly as the article shows it)', drop.out === '[Timer]\nOnCalendar=\nOnCalendar=*-*-* 03:00\nRandomizedDelaySec=15m', drop.out) run('sudo systemctl daemon-reload', { id: 'daemon-reload' }) const next = run('systemctl list-timers apt-daily-upgrade.timer --no-pager', { id: 'timer-0300' }) ctx.check('the next run is now between 03:00 and 03:15', /\s0?3:(0\d|1[0-5]):\d\d UTC/.test(next.out.split('\n')[1] ?? ''), next.out) // (hidden) the timer's own run: move it two minutes ahead with no random delay, wait, put 03:00 back const exitTs = () => L(`systemctl show apt-daily-upgrade.service -p ExecMainExitTimestampMonotonic --value`) const ts0 = exitTs() // the service may already have run once at boot (Persistent=true), so wait for a NEW run const at = L(`date -u -d '+2 min' +%H:%M`) L(`printf '%s\\n' '[Timer]' 'OnCalendar=' 'OnCalendar=*-*-* ${at}' 'RandomizedDelaySec=0' | sudo tee ${DROPIN} >/dev/null && sudo systemctl daemon-reload`) let state = '' for (let i = 0; i < 80; i++) { sleep(15000) state = `${exitTs()} ${L('systemctl is-active apt-daily-upgrade.service')}` if (!state.startsWith(`${ts0} `) && / inactive$/.test(state)) break } ctx.check(`(the timer fired on its own at ${at} UTC and its run finished)`, !state.startsWith(`${ts0} `) && / inactive$/.test(state), `${ts0} → ${state}`) L(`printf '%s\\n' '[Timer]' 'OnCalendar=' 'OnCalendar=*-*-* 03:00' 'RandomizedDelaySec=15m' | sudo tee ${DROPIN} >/dev/null && sudo systemctl daemon-reload`) // ── step 4: check that it ran ──────────────────────────────────────────────────────────── const svc = run('sudo journalctl -u apt-daily-upgrade.service --no-pager | tail -n 3', { id: 'journal' }) ctx.check('the journal shows the timer’s service ran and finished: "Finished apt-daily-upgrade.service"', /Finished apt-daily-upgrade\.service/.test(svc.out), svc.out) const log = run(`sudo tail -n 4 ${LOG}`, { id: 'uu-log' }) ctx.check('its log lists the packages it upgraded and ends "All upgrades installed"', /Packages that will be upgraded: /.test(log.out) && /INFO All upgrades installed/.test(log.out), log.out) const ls = run('ls /var/log/unattended-upgrades/', { id: 'log-dir-denied' }) ctx.check('the log folder is not readable without sudo', ls.exit !== 0 && /Permission denied/.test(ls.out), ls.out) const left = run('apt list --upgradable 2>/dev/null | grep -c security', { id: 'count-security-after' }) ctx.check('no security updates are left', left.out.split('\n').pop() === '0', left.out) const k2 = run('apt list --upgradable 2>/dev/null | grep linux-image', { id: 'kernel-still-pending' }) ctx.check('the kernel from noble-updates was left alone', /linux-image-virtual\/noble-updates /.test(k2.out), k2.out) const nor = run('ls /var/run/reboot-required', { id: 'no-reboot-flag' }) ctx.check('nothing it installed needs a reboot (no /var/run/reboot-required)', nor.exit !== 0 && /No such file/.test(nor.out), nor.out) // troubleshooting: starting it again the same day does nothing (the upgrade stamp) const before = L(`sudo cat ${LOG} | wc -l`) run('sudo systemctl start apt-daily-upgrade.service', { id: 'start-again', timeout: 600000 }) const after = L(`sudo cat ${LOG} | wc -l`) ctx.check('starting the service again the same day does nothing: the log gets no new line', /^\d+$/.test(before) && before === after, `${before} → ${after}`) const stamp = run('ls -l --time-style=+%F /var/lib/apt/periodic/upgrade-stamp', { id: 'stamp' }) ctx.check('…because /var/lib/apt/periodic/upgrade-stamp is dated today', new RegExp(L('date -u +%F')).test(stamp.out), stamp.out) // ── step 5: regular updates and an automatic reboot (optional) ─────────────────────────── L(`printf '%s\\n' 'Unattended-Upgrade::Allowed-Origins {' ' "\${distro_id}:\${distro_codename}-updates";' '};' 'Unattended-Upgrade::Automatic-Reboot "true";' 'Unattended-Upgrade::Automatic-Reboot-Time "02:00";' | sudo tee /etc/apt/apt.conf.d/52unattended-upgrades-local >/dev/null`) const local = run('cat /etc/apt/apt.conf.d/52unattended-upgrades-local', { id: '52local' }) ctx.check('(the 52unattended-upgrades-local file is exactly as the article shows it)', local.out === 'Unattended-Upgrade::Allowed-Origins {\n "${distro_id}:${distro_codename}-updates";\n};\nUnattended-Upgrade::Automatic-Reboot "true";\nUnattended-Upgrade::Automatic-Reboot-Time "02:00";', local.out) const merged = run('apt-config dump Unattended-Upgrade::Allowed-Origins', { id: 'origins-merged' }) ctx.check('the new file ADDS -updates to the list; the default origins stay', /-security";/.test(merged.out) && /-updates";/.test(merged.out), merged.out) const now = run('sudo unattended-upgrade -v 2>&1 | grep -E "^(Packages that will be upgraded|All upgrades installed|Found /var/run/reboot-required|Shutdown msg)"', { id: 'run-updates', timeout: 1800000 }) ctx.check('a run now installs the kernel from -updates', /Packages that will be upgraded: .*linux-image-virtual/.test(now.out), now.out) ctx.check('…finds /var/run/reboot-required and schedules the reboot for 02:00', /Found \/var\/run\/reboot-required, rebooting/.test(now.out) && /Reboot scheduled for .* 02:00:00 UTC/.test(now.out), now.out) const why = run('cat /var/run/reboot-required.pkgs', { id: 'reboot-pkgs' }) ctx.check('/var/run/reboot-required.pkgs names the new kernel', /^linux-image-\S+-generic$/m.test(why.out), why.out) const show = run('shutdown --show', { id: 'shutdown-show' }) ctx.check('shutdown --show confirms the reboot waiting for 02:00 UTC', /Reboot scheduled for .* 02:00:00 UTC/.test(show.out), show.out) const newKernel = (why.out.match(/^linux-image-(\S+)$/m) ?? [])[1] ?? '' const oldKernel = run('uname -r', { id: 'uname-before' }).out ctx.check('until the reboot the server still runs the old kernel', newKernel !== '' && oldKernel !== newKernel, `${oldKernel} (new: ${newKernel})`) // reboot now instead of waiting for 02:00 (the reader's `sudo reboot`) const secs = rebootBox() ctx.capture('sudo reboot', '', { id: 'reboot' }) ctx.check('the server comes back after the reboot', secs !== null, String(secs)) const k3 = run('uname -r', { id: 'uname-after' }) ctx.check('after the reboot it runs the new kernel', k3.out === newKernel, k3.out) const gone = run('ls /var/run/reboot-required', { id: 'flag-gone' }) ctx.check('and /var/run/reboot-required is gone', gone.exit !== 0, gone.out) const timer = run('systemctl list-timers apt-daily-upgrade.timer --no-pager', { id: 'timer-after-reboot' }) ctx.check('the 03:00 time survives the reboot', /\s0?3:(0\d|1[0-5]):\d\d UTC/.test(timer.out.split('\n')[1] ?? ''), timer.out) reportBox( ctx, L, 'A fresh Ubuntu 24.04 server from Ubuntu’s cloud image, with the updates published since the image was built still waiting, reached over SSH as a sudo user.', ['unattended-upgrades', 'apt', 'linux-image-virtual'], ) // ── undo: turn automatic upgrades off ──────────────────────────────────────────────────── L(`printf '%s\\n' 'APT::Periodic::Update-Package-Lists "1";' 'APT::Periodic::Unattended-Upgrade "0";' | sudo tee /etc/apt/apt.conf.d/20auto-upgrades >/dev/null`) const off = run('apt-config dump APT::Periodic::Unattended-Upgrade', { id: 'off' }) ctx.check('Unattended-Upgrade "0" turns the daily install off', /APT::Periodic::Unattended-Upgrade "0";/.test(off.out), off.out) L('sudo rm -f /var/lib/apt/periodic/upgrade-stamp') // so the stamp is not what stops it const b2 = L(`sudo cat ${LOG} | wc -l`) L('sudo systemctl start apt-daily-upgrade.service', 600000) const a2 = L(`sudo cat ${LOG} | wc -l`) ctx.check('(with "0" the timer’s service runs but does not upgrade: no new log line, even with no stamp)', /^\d+$/.test(b2) && b2 === a2, `${b2} → ${a2}`) }) export default check