ServerHandbook live check: run log ------------------------------------------------------------------------------ Article https://serverhandbook.com/kb/timezone-ubuntu-24-04 Check scripts/live/checks/timezone-ubuntu-24-04.mjs (sha256 cc368dc021be1902ca8223011dad6659591c68693f0376ba45e5de35c1b1a92b) Ran at 2026-11-11T23:04:45Z (266 s) Result PASS, all 34 claims held Tested on System Ubuntu 24.04.5 LTS Kernel 6.8.0-147-generic Package systemd 255.4-1ubuntu8.18 Package tzdata 2026e-0ubuntu0.24.04.1 Package cron 3.0pl1-184ubuntu2 Package rsyslog 8.2312.0-3ubuntu9.4 Setup A fresh Ubuntu 24.04 server from Ubuntu’s cloud image, on UTC as a provider hands it over, 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 (34), each with what the run saw ------------------------------------------------------------------------------ 1. ok a bare Ubuntu 24.04 server box (web-server) starts 2. ok a fresh cloud server is on UTC: "Time zone: Etc/UTC (UTC, +0000)" | Local time: Wed 2026-11-11 23:05:28 UTC | Universal time: Wed 2026-11-11 23:05:28 UTC | RTC time: Wed 2026-11-11 23:05:27 | Time zone: Etc/UTC (UTC, +0000) | System clock synchronized: yes | NTP service: active | RTC in local TZ: no 3. ok …and its clock is kept right by NTP: "System clock synchronized: yes", "NTP service: active" | Local time: Wed 2026-11-11 23:05:28 UTC | Universal time: Wed 2026-11-11 23:05:28 UTC | RTC time: Wed 2026-11-11 23:05:27 | Time zone: Etc/UTC (UTC, +0000) | System clock synchronized: yes | NTP service: active | RTC in local TZ: no 4. ok grep finds the exact name America/New_York | America/New_York 5. ok the list has several hundred names | 497 6. ok set-timezone prints nothing when it works 7. ok timedatectl now shows "Time zone: America/New_York" with its offset from UTC | Local time: Wed 2026-11-11 18:05:30 EST | Universal time: Wed 2026-11-11 23:05:30 UTC | RTC time: Wed 2026-11-11 23:05:30 | Time zone: America/New_York (EST, -0500) | System clock synchronized: yes | NTP service: active | RTC in local TZ: no 8. ok …Universal time is unchanged: only the way the time is shown changed | Local time: Wed 2026-11-11 18:05:30 EST | Universal time: Wed 2026-11-11 23:05:30 UTC | RTC time: Wed 2026-11-11 23:05:30 | Time zone: America/New_York (EST, -0500) | System clock synchronized: yes | NTP service: active | RTC in local TZ: no 9. ok date shows the New York time and zone | Wed Nov 11 18:05:30 EST 2026 10. ok the change is one symlink: /etc/localtime → /usr/share/zoneinfo/America/New_York | lrwxrwxrwx 1 root root 36 Nov 11 18:05 /etc/localtime -> /usr/share/zoneinfo/America/New_York 11. ok a misspelt name: "Failed to set time zone: Invalid or not installed time zone" | Failed to set time zone: Invalid or not installed time zone 'America/New_Yrok' 12. ok (cron was started before the change and has not been restarted) | 10598126 | > 13. ok crontab -l shows the test job | 7 18 * * * date > ~/cron-test.txt 14. ok cron ran the job at that New York time, without a restart | 18:07 → Wed Nov 11 18:07:01 EST 2026 15. ok systemd timers follow too: the automatic-update timer (OnCalendar 6:00) is now due at 06:xx New York time | NEXT LEFT LAST PASSED UNIT ACTIVATES | Thu 2026-11-12 06:32:59 EST 12h - - apt-daily-upgrade.timer apt-daily-upgrade.service | | 1 timers listed. | Pass --all to see loaded but inactive timers, too. 16. ok journalctl shows the change: "Changed time zone to 'America/New_York'" | Nov 11 18:05:30 web-server systemd-timedated[958]: Changed time zone to 'America/New_York' (EDT). 17. ok (the log line names the zone's SUMMER abbreviation, EDT, even in winter: timedated.c prints tzname[daylight]) | Nov 11 18:05:30 web-server systemd-timedated[958]: Changed time zone to 'America/New_York' (EDT). 18. ok (hidden) a program started before the change still prints UTC times | 23:07:05 UTC | 23:07:07 UTC 19. ok /var/log/syslog still stamps new lines with +00:00 (rsyslog started on UTC) | 2026-11-11T23:07:08.342959+00:00 web-server deploy: zone test 1 20. ok restarting rsyslog prints nothing 21. ok after the restart new lines carry the New York offset (-05:00 or -04:00) | 2026-11-11T23:07:08.342959+00:00 web-server deploy: zone test 1 | 2026-11-11T18:07:09.366948-05:00 web-server deploy: zone test 2 22. ok timedatectl does NOT update /etc/timezone: it still says Etc/UTC | Etc/UTC 23. ok dpkg-reconfigure tzdata reads the zone from /etc/localtime: "Current default time zone: 'America/New_York'" | Current default time zone: 'America/New_York' | Local time is now: Wed Nov 11 18:07:10 EST 2026. | Universal Time is now: Wed Nov 11 23:07:10 UTC 2026. 24. ok /etc/timezone now says America/New_York | America/New_York 25. ok the server comes back after the reboot | 12 26. ok after the reboot the zone is still America/New_York and the clock synchronized | Local time: Wed 2026-11-11 18:07:55 EST | Universal time: Wed 2026-11-11 23:07:55 UTC | RTC time: Wed 2026-11-11 23:07:55 | Time zone: America/New_York (EST, -0500) | System clock synchronized: yes | NTP service: active | RTC in local TZ: no 27. ok (after the reboot syslog lines carry the New York offset with no restart) | 2026-11-11T18:07:55.280209-05:00 web-server deploy: zone test 3 28. ok TZ=Asia/Tokyo date shows Tokyo time for that one command | Thu Nov 12 08:07:56 JST 2026 29. ok …and the server zone is unchanged | Wed Nov 11 18:07:56 EST 2026 30. ok a systemd timer can name its own zone: systemd-analyze shows when 09:00 Tokyo falls in server time | Original form: *-*-* 09:00 Asia/Tokyo | Normalized form: *-*-* 09:00:00 Asia/Tokyo | Next elapse: Wed 2026-11-11 19:00:00 EST | (in UTC): Thu 2026-11-12 00:00:00 UTC | From now: 52min left 31. ok (hidden) CRON_TZ=UTC is ignored: a job at UTC+2 min never ran, while the control job beside it did | 23:09 UTC / control Wed Nov 11 18:09:01 EST 2026 32. ok (tested on) the box reports its OS, kernel and the version of 4 package(s) | PRETTY_NAME="Ubuntu 24.04.5 LTS" | VIRT=none | KERNEL=6.8.0-147-generic | PKG cron 3.0pl1-184ubuntu2 | PKG rsyslog 8.2312.0-3ubuntu9.4 | PKG systemd 255.4-1ubuntu8.18 | PKG tzdata 2026e-0ubuntu0.24.04.1 33. ok after the undo the server is back on "Etc/UTC (UTC, +0000)" | Local time: Wed 2026-11-11 23:09:10 UTC | Universal time: Wed 2026-11-11 23:09:10 UTC | RTC time: Wed 2026-11-11 23:09:11 | Time zone: Etc/UTC (UTC, +0000) | System clock synchronized: yes | NTP service: active | RTC in local TZ: no 34. ok (/etc/localtime and /etc/timezone are back to Etc/UTC) | lrwxrwxrwx 1 root root 27 Nov 11 23:09 /etc/localtime -> /usr/share/zoneinfo/Etc/UTC | Etc/UTC ------------------------------------------------------------------------------ Commands and what they printed (28) ------------------------------------------------------------------------------ $ timedatectl Local time: Wed 2026-11-11 23:05:28 UTC Universal time: Wed 2026-11-11 23:05:28 UTC RTC time: Wed 2026-11-11 23:05:27 Time zone: Etc/UTC (UTC, +0000) System clock synchronized: yes NTP service: active RTC in local TZ: no $ timedatectl list-timezones | grep -i york America/New_York $ timedatectl list-timezones | wc -l 497 $ sudo timedatectl set-timezone America/New_York $ timedatectl Local time: Wed 2026-11-11 18:05:30 EST Universal time: Wed 2026-11-11 23:05:30 UTC RTC time: Wed 2026-11-11 23:05:30 Time zone: America/New_York (EST, -0500) System clock synchronized: yes NTP service: active RTC in local TZ: no $ date Wed Nov 11 18:05:30 EST 2026 $ ls -l /etc/localtime lrwxrwxrwx 1 root root 36 Nov 11 18:05 /etc/localtime -> /usr/share/zoneinfo/America/New_York $ sudo timedatectl set-timezone America/New_Yrok Failed to set time zone: Invalid or not installed time zone 'America/New_Yrok' $ crontab -l 7 18 * * * date > ~/cron-test.txt $ cat ~/cron-test.txt Wed Nov 11 18:07:01 EST 2026 $ systemctl list-timers apt-daily-upgrade.timer --no-pager NEXT LEFT LAST PASSED UNIT ACTIVATES Thu 2026-11-12 06:32:59 EST 12h - - apt-daily-upgrade.timer apt-daily-upgrade.service 1 timers listed. Pass --all to see loaded but inactive timers, too. $ sudo journalctl -q -t systemd-timedated --no-pager Nov 11 18:05:30 web-server systemd-timedated[958]: Changed time zone to 'America/New_York' (EDT). $ logger 'zone test 1' $ sudo grep 'zone test' /var/log/syslog 2026-11-11T23:07:08.342959+00:00 web-server deploy: zone test 1 $ sudo systemctl restart rsyslog $ logger 'zone test 2' $ sudo grep 'zone test' /var/log/syslog 2026-11-11T23:07:08.342959+00:00 web-server deploy: zone test 1 2026-11-11T18:07:09.366948-05:00 web-server deploy: zone test 2 $ cat /etc/timezone Etc/UTC $ sudo dpkg-reconfigure -f noninteractive tzdata Current default time zone: 'America/New_York' Local time is now: Wed Nov 11 18:07:10 EST 2026. Universal Time is now: Wed Nov 11 23:07:10 UTC 2026. $ cat /etc/timezone America/New_York $ sudo reboot $ timedatectl Local time: Wed 2026-11-11 18:07:55 EST Universal time: Wed 2026-11-11 23:07:55 UTC RTC time: Wed 2026-11-11 23:07:55 Time zone: America/New_York (EST, -0500) System clock synchronized: yes NTP service: active RTC in local TZ: no $ TZ=Asia/Tokyo date Thu Nov 12 08:07:56 JST 2026 $ systemd-analyze calendar '*-*-* 09:00 Asia/Tokyo' Original form: *-*-* 09:00 Asia/Tokyo Normalized form: *-*-* 09:00:00 Asia/Tokyo Next elapse: Wed 2026-11-11 19:00:00 EST (in UTC): Thu 2026-11-12 00:00:00 UTC From now: 52min left $ sudo timedatectl set-timezone Etc/UTC $ sudo dpkg-reconfigure -f noninteractive tzdata Current default time zone: 'Etc/UTC' Local time is now: Wed Nov 11 23:09:10 UTC 2026. Universal Time is now: Wed Nov 11 23:09:10 UTC 2026. $ sudo systemctl restart rsyslog $ timedatectl Local time: Wed 2026-11-11 23:09:10 UTC Universal time: Wed 2026-11-11 23:09:10 UTC RTC time: Wed 2026-11-11 23:09:11 Time zone: Etc/UTC (UTC, +0000) System clock synchronized: yes NTP service: active RTC in local TZ: no ------------------------------------------------------------------------------ The check's source (scripts/live/checks/timezone-ubuntu-24-04.mjs) As it ran. ------------------------------------------------------------------------------ /** * KB: Set the timezone on Ubuntu 24.04: check it, find the zone name, set it, what follows the change at once (cron, * systemd timers, journalctl) and what keeps the old zone (/var/log/syslog until rsyslog restarts, programs already * running, /etc/timezone), reboot, one job in another zone, undo. * * The server is a fresh VM box from Ubuntu's cloud image, reached as the sudo user `deploy`. It starts on Etc/UTC, as * every cloud server does. "cron follows the new zone without a restart" is proved with a real job set two minutes * ahead in the NEW zone while cron was started before the change; "CRON_TZ is ignored" with a control job beside it; * "a running program keeps the old zone" with a hidden loop started before the change. Every claim is one the * article makes. */ import { rebootBox } from '../box.mjs' import { bareBox, reportBox } from '../lib.mjs' export const meta = {} const ZONE = 'America/New_York' /** EST in winter, EDT in summer: the run's date decides, never the check. */ const NY = /\bE[SD]T\b/ /** timesyncd's first contact takes a few seconds after a boot; a reader logs in later than our runner does. */ const waitSync = (L) => L('for i in $(seq 90); do [ "$(timedatectl show -p NTPSynchronized --value)" = yes ] && break; sleep 2; done', 240000) const waitFor = (L, file, secs) => L(`for i in $(seq ${secs}); do [ -f ${file} ] && break; sleep 1; done; cat ${file} 2>/dev/null`, (secs + 30) * 1000) 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: what it is now ─────────────────────────────────────────────────────────────── waitSync(L) const st0 = run('timedatectl', { id: 'status-before' }) ctx.check('a fresh cloud server is on UTC: "Time zone: Etc/UTC (UTC, +0000)"', /Time zone: Etc\/UTC \(UTC, \+0000\)/.test(st0.out), st0.out) ctx.check('…and its clock is kept right by NTP: "System clock synchronized: yes", "NTP service: active"', /System clock synchronized: yes/.test(st0.out) && /NTP service: active/.test(st0.out), st0.out) // ── step 2: find the name ──────────────────────────────────────────────────────────────── const find = run('timedatectl list-timezones | grep -i york', { id: 'find' }) ctx.check(`grep finds the exact name ${ZONE}`, find.out === ZONE, find.out) const count = run('timedatectl list-timezones | wc -l', { id: 'count' }) ctx.check('the list has several hundred names', Number(count.out) > 300, count.out) // a program already running before the change (hidden): prints the time every 2 s L(`nohup python3 -c " import time while True: open('/tmp/clock.txt', 'a').write(time.strftime('%H:%M:%S %Z') + '\\n'); time.sleep(2) " >/dev/null 2>&1 &`) const cronStart = L('systemctl show cron -p ActiveEnterTimestampMonotonic --value') // ── step 3: set it ─────────────────────────────────────────────────────────────────────── const set = run(`sudo timedatectl set-timezone ${ZONE}`, { id: 'set' }) ctx.check('set-timezone prints nothing when it works', set.exit === 0 && set.out === '', set.out) const st1 = run('timedatectl', { id: 'status-after' }) ctx.check(`timedatectl now shows "Time zone: ${ZONE}" with its offset from UTC`, new RegExp(`Time zone: ${ZONE} \\(E[SD]T, -0[45]00\\)`).test(st1.out), st1.out) ctx.check('…Universal time is unchanged: only the way the time is shown changed', /Universal time: .* UTC/.test(st1.out), st1.out) const date = run('date', { id: 'date' }) ctx.check('date shows the New York time and zone', NY.test(date.out), date.out) const link = run('ls -l /etc/localtime', { id: 'localtime' }) ctx.check('the change is one symlink: /etc/localtime → /usr/share/zoneinfo/America/New_York', new RegExp(`/etc/localtime -> /usr/share/zoneinfo/${ZONE}$`).test(link.out), link.out) const typo = run('sudo timedatectl set-timezone America/New_Yrok', { id: 'typo' }) ctx.check('a misspelt name: "Failed to set time zone: Invalid or not installed time zone"', typo.exit !== 0 && typo.out === "Failed to set time zone: Invalid or not installed time zone 'America/New_Yrok'", typo.out) // ── step 4: what follows at once ───────────────────────────────────────────────────────── // cron: a job two minutes ahead in the NEW zone (the reader adds it with crontab -e) ctx.check('(cron was started before the change and has not been restarted)', cronStart !== '' && L('systemctl show cron -p ActiveEnterTimestampMonotonic --value') === cronStart, cronStart) const [mm, hh] = L("date -d '+2 min' '+%M %H'").split(' ') L(`echo '${Number(mm)} ${Number(hh)} * * * date > ~/cron-test.txt' | crontab -`) const cl = run('crontab -l', { id: 'cron-line' }) ctx.check('crontab -l shows the test job', cl.out === `${Number(mm)} ${Number(hh)} * * * date > ~/cron-test.txt`, cl.out) waitFor(L, '~/cron-test.txt', 200) const cr = run('cat ~/cron-test.txt', { id: 'cron-ran' }) ctx.check('cron ran the job at that New York time, without a restart', NY.test(cr.out) && cr.out.includes(` ${hh}:${mm}:`), `${hh}:${mm} → ${cr.out}`) const tm = run('systemctl list-timers apt-daily-upgrade.timer --no-pager', { id: 'timer' }) ctx.check('systemd timers follow too: the automatic-update timer (OnCalendar 6:00) is now due at 06:xx New York time', /\b06:\d\d:\d\d E[SD]T\b/.test(tm.out), tm.out) const jl = run('sudo journalctl -q -t systemd-timedated --no-pager', { id: 'journal' }) ctx.check(`journalctl shows the change: "Changed time zone to '${ZONE}'"`, jl.out.includes(`Changed time zone to '${ZONE}' (`), jl.out) ctx.check('(the log line names the zone\'s SUMMER abbreviation, EDT, even in winter: timedated.c prints tzname[daylight])', jl.out.includes(`'${ZONE}' (EDT).`), jl.out) // ── step 5: what keeps the old zone ────────────────────────────────────────────────────── const clock = L('sleep 5; tail -n 2 /tmp/clock.txt') ctx.check('(hidden) a program started before the change still prints UTC times', /UTC$/.test(clock) && !NY.test(clock), clock) L('pkill -f /tmp/clock.txt; rm -f /tmp/clock.txt') run("logger 'zone test 1'", { id: 'logger-1' }) const s1 = run("sudo grep 'zone test' /var/log/syslog", { id: 'syslog-1' }) ctx.check('/var/log/syslog still stamps new lines with +00:00 (rsyslog started on UTC)', /\+00:00 web-server deploy: zone test 1$/m.test(s1.out), s1.out) const rs = run('sudo systemctl restart rsyslog', { id: 'rsyslog-restart' }) ctx.check('restarting rsyslog prints nothing', rs.exit === 0 && rs.out === '', rs.out) run("logger 'zone test 2'", { id: 'logger-2' }) const s2 = run("sudo grep 'zone test' /var/log/syslog", { id: 'syslog-2' }) ctx.check('after the restart new lines carry the New York offset (-05:00 or -04:00)', /-0[45]:00 web-server deploy: zone test 2$/m.test(s2.out), s2.out) const tz0 = run('cat /etc/timezone', { id: 'etc-timezone' }) ctx.check('timedatectl does NOT update /etc/timezone: it still says Etc/UTC', tz0.out === 'Etc/UTC', tz0.out) const rc = run('sudo dpkg-reconfigure -f noninteractive tzdata', { id: 'reconfigure' }) ctx.check(`dpkg-reconfigure tzdata reads the zone from /etc/localtime: "Current default time zone: '${ZONE}'"`, rc.out.includes(`Current default time zone: '${ZONE}'`), rc.out) const tz1 = run('cat /etc/timezone', { id: 'etc-timezone-2' }) ctx.check(`/etc/timezone now says ${ZONE}`, tz1.out === ZONE, tz1.out) // ── step 6: reboot ─────────────────────────────────────────────────────────────────────── const secs = rebootBox() ctx.capture('sudo reboot', '', { id: 'reboot' }) ctx.check('the server comes back after the reboot', typeof secs === 'number', String(secs)) waitSync(L) const st2 = run('timedatectl', { id: 'status-reboot' }) ctx.check(`after the reboot the zone is still ${ZONE} and the clock synchronized`, st2.out.includes(`Time zone: ${ZONE}`) && /System clock synchronized: yes/.test(st2.out), st2.out) L("logger 'zone test 3'") ctx.check('(after the reboot syslog lines carry the New York offset with no restart)', /-0[45]:00 web-server deploy: zone test 3$/m.test(L("sudo grep 'zone test 3' /var/log/syslog")), L("sudo grep 'zone test 3' /var/log/syslog")) // ── another zone for one command or one job ────────────────────────────────────────────── const tok = run('TZ=Asia/Tokyo date', { id: 'tz-env' }) ctx.check('TZ=Asia/Tokyo date shows Tokyo time for that one command', /\bJST\b/.test(tok.out), tok.out) ctx.check('…and the server zone is unchanged', NY.test(L('date')), L('date')) const cal = run("systemd-analyze calendar '*-*-* 09:00 Asia/Tokyo'", { id: 'calendar' }) ctx.check('a systemd timer can name its own zone: systemd-analyze shows when 09:00 Tokyo falls in server time', /Normalized form: \*-\*-\* 09:00:00 Asia\/Tokyo/.test(cal.out) && /Next elapse: .* E[SD]T/.test(cal.out), cal.out) // CRON_TZ: Ubuntu's cron ignores it (hidden; a control job beside it proves cron is running) const [um, uh] = L("TZ=UTC date -d '+2 min' '+%M %H'").split(' ') const [cm, ch] = L("date -d '+2 min' '+%M %H'").split(' ') L(`printf 'CRON_TZ=UTC\\n${Number(um)} ${Number(uh)} * * * date > ~/crontz.txt\\n${Number(cm)} ${Number(ch)} * * * date > ~/control.txt\\n' | crontab -`) const control = waitFor(L, '~/control.txt', 200) L('sleep 5') ctx.check('(hidden) CRON_TZ=UTC is ignored: a job at UTC+2 min never ran, while the control job beside it did', NY.test(control) && L('ls ~/crontz.txt 2>&1').includes('No such file'), `${uh}:${um} UTC / control ${control}`) L('crontab -r; rm -f ~/cron-test.txt ~/control.txt ~/crontz.txt') reportBox( ctx, L, 'A fresh Ubuntu 24.04 server from Ubuntu’s cloud image, on UTC as a provider hands it over, reached over SSH as a sudo user.', ['systemd', 'tzdata', 'cron', 'rsyslog'], ) // ── undo ───────────────────────────────────────────────────────────────────────────────── run('sudo timedatectl set-timezone Etc/UTC', { id: 'undo-set' }) run('sudo dpkg-reconfigure -f noninteractive tzdata', { id: 'undo-reconfigure' }) run('sudo systemctl restart rsyslog', { id: 'undo-rsyslog' }) const back = run('timedatectl', { id: 'undo-status' }) ctx.check('after the undo the server is back on "Etc/UTC (UTC, +0000)"', /Time zone: Etc\/UTC \(UTC, \+0000\)/.test(back.out), back.out) ctx.check('(/etc/localtime and /etc/timezone are back to Etc/UTC)', /zoneinfo\/Etc\/UTC$/.test(L('ls -l /etc/localtime')) && L('cat /etc/timezone') === 'Etc/UTC', L('ls -l /etc/localtime; cat /etc/timezone')) }) export default check