ServerHandbook live check: run log ------------------------------------------------------------------------------ Check scripts/live/checks/journalctl-logs-ubuntu.mjs (sha256 a12607a19bbe35fefcd725b22930eb189d3849467d5968e62d8bf49f3e9270f3) Ran at 2026-11-19T21:23:42Z (48 s) Result PASS, all 25 claims held Tested on System Ubuntu 24.04.5 LTS Kernel 6.8.0-147-generic Package systemd 255.4-1ubuntu8.18 Setup A fresh Ubuntu 24.04 server (a VM from Ubuntu’s cloud image) reached over SSH as the sudo user deploy; the logs come from a small demo job written for the test, nothing downloaded. 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 ------------------------------------------------------------------------------ What the steps changed on the server (recorded before the first step and after the last) Packages added (0) Packages upgraded (0) Packages removed (0) Services enabled at boot (0) Services disabled (0) Listening sockets opened (0) Listening sockets closed (0) Files added in /etc (1) /etc/systemd/journald.conf.d/size.conf Files changed in /etc (4) /etc/group /etc/group- /etc/gshadow /etc/gshadow- Files removed from /etc (0) Disk used on / (includes logs written during the run): +7.2 MB ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Claims (25), each with what the run saw ------------------------------------------------------------------------------ 1. ok a bare Ubuntu 24.04 server box (web-server) starts 2. ok (setup) the sudo user deploy is not in adm or systemd-journal | deploy sudo users 3. ok without sudo: no backup lines, and a hint naming the groups adm and systemd-journal | Hint: You are currently not seeing messages from other users and the system. | Users in groups 'adm', 'systemd-journal' can see all messages. | Pass -q to turn off this notice. | -- No entries -- 4. ok sudo journalctl -u backup: the job's three lines and systemd's own lines about it | Nov 19 21:24:00 web-server systemd[1]: Starting backup.service - Nightly backup... | Nov 19 21:24:00 web-server backup-job[1627]: backup started | Nov 19 21:24:00 web-server backup-job[1627]: backup: 2 files skipped | Nov 19 21:24:00 web-server backup-job[1627]: backup failed: disk full | Nov 19 21:24:00 web-server systemd[1]: backup.service: Main process exited, code=exited, status=1/FAILURE | Nov 19 21:24:00 web-server systemd[1]: backup.service: Failed with result 'exit-code'. | Nov 19 21:24:00 web-server systemd[1]: Failed to start backup.service - Nightly backup. 5. ok the prefix is gone from the text: systemd read it as the priority | Nov 19 21:24:00 web-server systemd[1]: Starting backup.service - Nightly backup... | Nov 19 21:24:00 web-server backup-job[1627]: backup started | Nov 19 21:24:00 web-server backup-job[1627]: backup: 2 files skipped | Nov 19 21:24:00 web-server backup-job[1627]: backup failed: disk full | Nov 19 21:24:00 web-server systemd[1]: backup.service: Main process exited, code=exited, status=1/FAILURE | Nov 19 21:24:00 web-server systemd[1]: backup.service: Failed with result 'exit-code'. | Nov 19 21:24:00 web-server systemd[1]: Failed to start backup.service - Nightly backup. 6. ok -n 2 shows only the last two lines | Nov 19 21:24:00 web-server systemd[1]: backup.service: Failed with result 'exit-code'. | Nov 19 21:24:00 web-server systemd[1]: Failed to start backup.service - Nightly backup. 7. ok -f prints new lines as they come (a second run of the job shows up) | [1] 2030 | Job for backup.service failed because the control process exited with error code. | See "systemctl status backup.service" and "journalctl -xeu backup.service" for details. | Nov 19 21:24:06 web-server systemd[1]: Starting backup.service - Nightly backup... | Nov 19 21:24:06 web-server backup-job[2039]: backup started | Nov 19 21:24:06 web-server backup-job[2039]: backup: 2 files skipped | Nov 19 21:24:06 web-server backup-job[2039]: backup failed: disk full | Nov 19 21:24:06 web-server systemd[1]: backup.service: Main process exited, code=exited, status=1/FAILURE | Nov 19 21:24:06 web-server systemd[1]: backup.service: Failed with result 'exit-code'. | Nov 19 21:24:06 web-server systemd[1]: Failed to start backup.service - Nightly backup. | [1]+ Exit 1 ( sleep 2; sudo systemctl start backup ) 8. ok -p err keeps the error lines and drops the info and warning ones | Nov 19 21:24:00 web-server backup-job[1627]: backup failed: disk full | Nov 19 21:24:00 web-server systemd[1]: Failed to start backup.service - Nightly backup. | Nov 19 21:24:06 web-server backup-job[2039]: backup failed: disk full | Nov 19 21:24:06 web-server systemd[1]: Failed to start backup.service - Nightly backup. 9. ok --since "10 min ago" accepts plain words | Nov 19 21:24:06 web-server systemd[1]: backup.service: Main process exited, code=exited, status=1/FAILURE | Nov 19 21:24:06 web-server systemd[1]: backup.service: Failed with result 'exit-code'. | Nov 19 21:24:06 web-server systemd[1]: Failed to start backup.service - Nightly backup. 10. ok -g searches the message text | Nov 19 21:24:00 web-server backup-job[1627]: backup failed: disk full | Nov 19 21:24:06 web-server backup-job[2039]: backup failed: disk full 11. ok -o cat prints the messages without date, host and process | backup failed: disk full | backup.service: Main process exited, code=exited, status=1/FAILURE | backup.service: Failed with result 'exit-code'. | Failed to start backup.service - Nightly backup. 12. ok /var/log/journal exists: the journal is kept on disk | /var/log/journal 13. ok the server comes back after the reboot | 12 14. ok --list-boots lists the boot before this one (index -1) and this one (0) | IDX BOOT ID FIRST ENTRY LAST ENTRY | -1 aaba4b02cee8499d831e0a243dc81306 Thu 2026-11-19 21:23:47 UTC Thu 2026-11-19 21:24:13 UTC | 0 a347294747d74965a1164c615c639e02 Thu 2026-11-19 21:24:19 UTC Thu 2026-11-19 21:24:25 UTC 15. ok -b (this boot): no entries, the job has not run since the reboot | -- No entries -- 16. ok -b -1 (the boot before): the lines are still there | Nov 19 21:24:06 web-server backup-job[2039]: backup started | Nov 19 21:24:06 web-server backup-job[2039]: backup: 2 files skipped | Nov 19 21:24:06 web-server backup-job[2039]: backup failed: disk full | Nov 19 21:24:06 web-server systemd[1]: backup.service: Main process exited, code=exited, status=1/FAILURE | Nov 19 21:24:06 web-server systemd[1]: backup.service: Failed with result 'exit-code'. | Nov 19 21:24:06 web-server systemd[1]: Failed to start backup.service - Nightly backup. 17. ok --disk-usage: "Archived and active journals take up …" | Archived and active journals take up 22.8M in the file system. 18. ok the size drop-in is written | [Journal] | SystemMaxUse=200M 19. ok journald restarts 20. ok journald's own start line reports the new limit (max 200M) | Nov 19 21:24:27 web-server systemd-journald[1449]: System Journal (/var/log/journal/a4d62ba4c685470c9483a0edfb36a449) is 22.8M, max 200.0M, 177.1M free. 21. ok --vacuum-time runs and reports what it freed | Vacuuming done, freed 0B of archived journals from /var/log/journal. | Vacuuming done, freed 0B of archived journals from /run/log/journal. | Vacuuming done, freed 0B of archived journals from /var/log/journal/a4d62ba4c685470c9483a0edfb36a449. 22. ok usermod adds deploy to systemd-journal and prints nothing 23. ok a new login is in the group | deploy sudo users systemd-journal 24. ok now journalctl works without sudo | Nov 19 21:24:00 web-server backup-job[1627]: backup failed: disk full | Nov 19 21:24:06 web-server backup-job[2039]: backup failed: disk full 25. ok (tested on) the box reports its OS, kernel and the version of 1 package(s) | PRETTY_NAME="Ubuntu 24.04.5 LTS" | VIRT=none | KERNEL=6.8.0-147-generic | PKG systemd 255.4-1ubuntu8.18 ------------------------------------------------------------------------------ Commands and what they printed (22) ------------------------------------------------------------------------------ $ journalctl -u backup --no-pager Hint: You are currently not seeing messages from other users and the system. Users in groups 'adm', 'systemd-journal' can see all messages. Pass -q to turn off this notice. -- No entries -- $ sudo journalctl -u backup --no-pager Nov 19 21:24:00 web-server systemd[1]: Starting backup.service - Nightly backup... Nov 19 21:24:00 web-server backup-job[1627]: backup started Nov 19 21:24:00 web-server backup-job[1627]: backup: 2 files skipped Nov 19 21:24:00 web-server backup-job[1627]: backup failed: disk full Nov 19 21:24:00 web-server systemd[1]: backup.service: Main process exited, code=exited, status=1/FAILURE Nov 19 21:24:00 web-server systemd[1]: backup.service: Failed with result 'exit-code'. Nov 19 21:24:00 web-server systemd[1]: Failed to start backup.service - Nightly backup. $ sudo journalctl -u backup --no-pager -n 2 Nov 19 21:24:00 web-server systemd[1]: backup.service: Failed with result 'exit-code'. Nov 19 21:24:00 web-server systemd[1]: Failed to start backup.service - Nightly backup. $ (sleep 2; sudo systemctl start backup) & sudo timeout 6 journalctl -u backup -f -n 0 [1] 2030 Job for backup.service failed because the control process exited with error code. See "systemctl status backup.service" and "journalctl -xeu backup.service" for details. Nov 19 21:24:06 web-server systemd[1]: Starting backup.service - Nightly backup... Nov 19 21:24:06 web-server backup-job[2039]: backup started Nov 19 21:24:06 web-server backup-job[2039]: backup: 2 files skipped Nov 19 21:24:06 web-server backup-job[2039]: backup failed: disk full Nov 19 21:24:06 web-server systemd[1]: backup.service: Main process exited, code=exited, status=1/FAILURE Nov 19 21:24:06 web-server systemd[1]: backup.service: Failed with result 'exit-code'. Nov 19 21:24:06 web-server systemd[1]: Failed to start backup.service - Nightly backup. [1]+ Exit 1 ( sleep 2; sudo systemctl start backup ) $ sudo journalctl -u backup -p err --no-pager Nov 19 21:24:00 web-server backup-job[1627]: backup failed: disk full Nov 19 21:24:00 web-server systemd[1]: Failed to start backup.service - Nightly backup. Nov 19 21:24:06 web-server backup-job[2039]: backup failed: disk full Nov 19 21:24:06 web-server systemd[1]: Failed to start backup.service - Nightly backup. $ sudo journalctl -u backup --since "10 min ago" --no-pager | tail -n 3 Nov 19 21:24:06 web-server systemd[1]: backup.service: Main process exited, code=exited, status=1/FAILURE Nov 19 21:24:06 web-server systemd[1]: backup.service: Failed with result 'exit-code'. Nov 19 21:24:06 web-server systemd[1]: Failed to start backup.service - Nightly backup. $ sudo journalctl -u backup -g "disk full" --no-pager Nov 19 21:24:00 web-server backup-job[1627]: backup failed: disk full Nov 19 21:24:06 web-server backup-job[2039]: backup failed: disk full $ sudo journalctl -u backup -o cat --no-pager -n 4 backup failed: disk full backup.service: Main process exited, code=exited, status=1/FAILURE backup.service: Failed with result 'exit-code'. Failed to start backup.service - Nightly backup. $ ls -d /var/log/journal /var/log/journal $ sudo reboot $ sudo journalctl --list-boots --no-pager IDX BOOT ID FIRST ENTRY LAST ENTRY -1 aaba4b02cee8499d831e0a243dc81306 Thu 2026-11-19 21:23:47 UTC Thu 2026-11-19 21:24:13 UTC 0 a347294747d74965a1164c615c639e02 Thu 2026-11-19 21:24:19 UTC Thu 2026-11-19 21:24:25 UTC $ sudo journalctl -u backup -b --no-pager -- No entries -- $ sudo journalctl -u backup -b -1 --no-pager -n 6 Nov 19 21:24:06 web-server backup-job[2039]: backup started Nov 19 21:24:06 web-server backup-job[2039]: backup: 2 files skipped Nov 19 21:24:06 web-server backup-job[2039]: backup failed: disk full Nov 19 21:24:06 web-server systemd[1]: backup.service: Main process exited, code=exited, status=1/FAILURE Nov 19 21:24:06 web-server systemd[1]: backup.service: Failed with result 'exit-code'. Nov 19 21:24:06 web-server systemd[1]: Failed to start backup.service - Nightly backup. $ sudo journalctl --disk-usage Archived and active journals take up 22.8M in the file system. $ sudo mkdir -p /etc/systemd/journald.conf.d $ sudo tee /etc/systemd/journald.conf.d/size.conf <<'EOF' $ [Journal] $ SystemMaxUse=200M $ EOF [Journal] SystemMaxUse=200M $ sudo systemctl restart systemd-journald $ sudo journalctl -u systemd-journald -b --no-pager | grep -m 1 -i "max 200" Nov 19 21:24:27 web-server systemd-journald[1449]: System Journal (/var/log/journal/a4d62ba4c685470c9483a0edfb36a449) is 22.8M, max 200.0M, 177.1M free. $ sudo journalctl --vacuum-time=2weeks Vacuuming done, freed 0B of archived journals from /var/log/journal. Vacuuming done, freed 0B of archived journals from /run/log/journal. Vacuuming done, freed 0B of archived journals from /var/log/journal/a4d62ba4c685470c9483a0edfb36a449. $ sudo usermod -aG systemd-journal deploy $ id -nG deploy sudo users systemd-journal $ journalctl -u backup -b -1 -g "disk full" --no-pager Nov 19 21:24:00 web-server backup-job[1627]: backup failed: disk full Nov 19 21:24:06 web-server backup-job[2039]: backup failed: disk full ------------------------------------------------------------------------------ The check's source (scripts/live/checks/journalctl-logs-ubuntu.mjs) As it ran. ------------------------------------------------------------------------------ /** * KB how-to: read a service's logs with journalctl on Ubuntu 26.04 and 24.04 (run per release, --releases=26.04,24.04). * A small demo job (hidden setup, nothing downloaded) logs three lines at three priorities through stdout, using the * `` prefixes systemd reads by default; then the page's commands: what a normal user sees (the hint), -u, -n, -f, * -p err, --since, -g, -o cat, persistence across a reboot (--list-boots, -b -1), --disk-usage, a size limit in a * journald drop-in, --vacuum-time, and the group that lets a user read the journal without sudo. * The server is a fresh VM box from Ubuntu's cloud image, reached as the sudo user `deploy`. */ import { spawnSync } from 'node:child_process' import { rebootBox } from '../box.mjs' import { bareBox, reportBox } from '../lib.mjs' const RELEASE = process.env.LIVE_BOX_RELEASE || '24.04' const sleep = (s) => spawnSync('sleep', [String(s)]) const JOB = [ '#!/bin/sh', 'echo "<6>backup started"', 'echo "<4>backup: 2 files skipped"', 'echo "<3>backup failed: disk full"', 'exit 1', ].join('\n') const SIZE = ['[Journal]', 'SystemMaxUse=200M'].join('\n') const check = (ctx) => bareBox(ctx, async ({ sudoUser }) => { const { run, L } = sudoUser() L('sudo true') // ── hidden: the demo job, run once ─────────────────────────────────────────────────────── L(`sudo tee /usr/local/bin/backup-job > /dev/null <<'EOF'\n${JOB}\nEOF\nsudo chmod +x /usr/local/bin/backup-job`) L(`sudo tee /etc/systemd/system/backup.service > /dev/null <<'EOF'\n[Unit]\nDescription=Nightly backup\n\n[Service]\nType=oneshot\nExecStart=/usr/local/bin/backup-job\nEOF\nsudo systemctl daemon-reload`) L('sudo systemctl start backup; true') sleep(1) const groups = L('id -nG') ctx.check('(setup) the sudo user deploy is not in adm or systemd-journal', !/\b(adm|systemd-journal)\b/.test(groups), groups) // ── 1. without sudo ────────────────────────────────────────────────────────────────────── const nos = run('journalctl -u backup --no-pager', { id: 'no-sudo' }) ctx.check('without sudo: no backup lines, and a hint naming the groups adm and systemd-journal', !/backup failed/.test(nos.out) && /adm/.test(nos.out) && /systemd-journal/.test(nos.out), nos.out) // ── 2. one service ─────────────────────────────────────────────────────────────────────── const all = run('sudo journalctl -u backup --no-pager', { id: 'unit' }) ctx.check('sudo journalctl -u backup: the job\'s three lines and systemd\'s own lines about it', /backup started/.test(all.out) && /2 files skipped/.test(all.out) && /backup failed: disk full/.test(all.out) && /backup\.service/.test(all.out), all.out) ctx.check('the prefix is gone from the text: systemd read it as the priority', !/<[346]>/.test(all.out), all.out) const last = run('sudo journalctl -u backup --no-pager -n 2', { id: 'last-2' }) ctx.check('-n 2 shows only the last two lines', last.out.split('\n').filter((l) => /^\w{3} \d+ /.test(l)).length === 2, last.out) // ── 3. follow ──────────────────────────────────────────────────────────────────────────── const fol = run('(sleep 2; sudo systemctl start backup) & sudo timeout 6 journalctl -u backup -f -n 0', { id: 'follow', timeout: 60000 }) ctx.check('-f prints new lines as they come (a second run of the job shows up)', /backup started/.test(fol.out) && /disk full/.test(fol.out), fol.out) // ── 4. filter ──────────────────────────────────────────────────────────────────────────── const err = run('sudo journalctl -u backup -p err --no-pager', { id: 'priority' }) ctx.check('-p err keeps the error lines and drops the info and warning ones', /disk full/.test(err.out) && !/backup started/.test(err.out) && !/files skipped/.test(err.out), err.out) const since = run('sudo journalctl -u backup --since "10 min ago" --no-pager | tail -n 3', { id: 'since' }) ctx.check('--since "10 min ago" accepts plain words', since.exit === 0 && /backup/.test(since.out), since.out) const grep = run('sudo journalctl -u backup -g "disk full" --no-pager', { id: 'grep' }) ctx.check('-g searches the message text', /disk full/.test(grep.out) && !/files skipped/.test(grep.out), grep.out) const cat = run('sudo journalctl -u backup -o cat --no-pager -n 4', { id: 'cat' }) ctx.check('-o cat prints the messages without date, host and process', /^backup failed: disk full$/m.test(cat.out) && !/^\w{3} \d+ /m.test(cat.out), cat.out) // ── 5. after a reboot ──────────────────────────────────────────────────────────────────── const jdir = run('ls -d /var/log/journal', { id: 'journal-dir' }) ctx.check('/var/log/journal exists: the journal is kept on disk', jdir.out === '/var/log/journal', jdir.out) const secs = rebootBox() ctx.capture('sudo reboot', '', { id: 'reboot' }) ctx.check('the server comes back after the reboot', typeof secs === 'number', String(secs)) const boots = run('sudo journalctl --list-boots --no-pager', { id: 'list-boots' }) ctx.check('--list-boots lists the boot before this one (index -1) and this one (0)', /^\s*-1\s/m.test(boots.out) && /^\s*0\s/m.test(boots.out), boots.out) const now = run('sudo journalctl -u backup -b --no-pager', { id: 'this-boot' }) ctx.check('-b (this boot): no entries, the job has not run since the reboot', /No entries/.test(now.out), now.out) const prev = run('sudo journalctl -u backup -b -1 --no-pager -n 6', { id: 'last-boot' }) ctx.check('-b -1 (the boot before): the lines are still there', /disk full/.test(prev.out), prev.out) // ── 6. disk space ──────────────────────────────────────────────────────────────────────── const du = run('sudo journalctl --disk-usage', { id: 'disk-usage' }) ctx.check('--disk-usage: "Archived and active journals take up …"', /Archived and active journals take up \S+/.test(du.out), du.out) run('sudo mkdir -p /etc/systemd/journald.conf.d', { id: 'conf-dir' }) const sz = run(`sudo tee /etc/systemd/journald.conf.d/size.conf <<'EOF'\n${SIZE}\nEOF`, { id: 'size-conf' }) ctx.check('the size drop-in is written', sz.out === SIZE, sz.out) const rs = run('sudo systemctl restart systemd-journald', { id: 'restart-journald' }) ctx.check('journald restarts', rs.exit === 0, rs.out) const lim = run('sudo journalctl -u systemd-journald -b --no-pager | grep -m 1 -i "max 200"', { id: 'limit-applied' }) ctx.check('journald\'s own start line reports the new limit (max 200M)', /max 200(\.0)?M/.test(lim.out), lim.out) const vac = run('sudo journalctl --vacuum-time=2weeks', { id: 'vacuum' }) ctx.check('--vacuum-time runs and reports what it freed', vac.exit === 0 && /freed|Vacuuming done/.test(vac.out), vac.out) // ── 7. read it without sudo ────────────────────────────────────────────────────────────── const um = run('sudo usermod -aG systemd-journal deploy', { id: 'usermod' }) ctx.check('usermod adds deploy to systemd-journal and prints nothing', um.exit === 0 && um.out === '', um.out) const g2 = run('id -nG', { id: 'groups-after' }) ctx.check('a new login is in the group', /\bsystemd-journal\b/.test(g2.out), g2.out) const ok = run('journalctl -u backup -b -1 -g "disk full" --no-pager', { id: 'no-sudo-after' }) ctx.check('now journalctl works without sudo', /disk full/.test(ok.out) && !/systemd-journal' can see/.test(ok.out), ok.out) ctx.stepsDone() reportBox( ctx, L, `A fresh Ubuntu ${RELEASE} server (a VM from Ubuntu’s cloud image) reached over SSH as the sudo user deploy; the logs come from a small demo job written for the test, nothing downloaded.`, ['systemd'], ) }) export default check