Where to start First steps track · 15 stages
Linux Labs

timedatectl — time, time zone, and synchronization

5 min Ubuntu 24.04 · systemd

Manages system time and NTP; set-time requires turning off set-ntp first, or the time reverts.

Cheat sheet

6 commands Printable version
  • timedatectl time, time zone, sync status
  • sudo timedatectl set-timezone Europe/Moscow change the time zone
  • sudo timedatectl set-ntp true enable NTP synchronization
  • timedatectl timesync-status server, delay, offset
  • chronyc tracking the same with chrony
  • date -u current time in UTC

Overview

Accurate time matters: TLS certificates, logs, cron, clusters, Kerberos all break when it drifts. On Ubuntu, systemd manages time (systemd-timesyncd is a lightweight NTP client; chrony keeps the clock more precisely and serves time to other machines).

bash
timedatectl                       # time, time zone, sync status
timedatectl list-timezones        # the list of zones
timedatectl list-timezones | grep -i moscow

Options

6

set-time requires auto-synchronization to be off: with set-ntp true active, the service immediately reverts the time, and a manual change will look like it didn't take effect. set-local-rtc switches the hardware clock's format between UTC (correct for a Linux server) and local time (only needed for dual-booting with Windows).

Option What it does Example
set-timezone ZONE Change the time zone — switches the /etc/localtime symlink. sudo timedatectl set-timezone Europe/Moscow
set-ntp true|false Enable or disable automatic NTP time synchronization. sudo timedatectl set-ntp true
set-time 'YYYY-MM-DD HH:MM:SS' Set the time manually; only works while set-ntp is disabled. sudo timedatectl set-time '2026-01-01 12:00:00'
timesync-status Show the sync server, delay, and time offset. timedatectl timesync-status
list-timezones List the available time zones. timedatectl list-timezones
set-local-rtc 0|1 Keep the hardware clock in UTC (0, recommended) or local time (1). sudo timedatectl set-local-rtc 0

Nothing found. Try a shorter query.

Recipes

3

Commands

bash
sudo timedatectl set-timezone Europe/Moscow  # zone: /etc/localtime
sudo timedatectl set-ntp true          # enable NTP synchronization
timedatectl timesync-status            # server, offset (timesyncd)
timedatectl show-timesync --all        # all timesyncd details
sudo timedatectl set-ntp false         # before set-time
sudo timedatectl set-time '2026-01-01 12:00:00'
sudo timedatectl set-local-rtc 0       # RTC in UTC (1 is for Windows)
date ; date -u                         # local / UTC
date +%s                               # unix time (epoch)
hwclock --show                         # the hardware clock (RTC)

Time zone

text
student@node1:~$ sudo timedatectl set-timezone Europe/Moscow
student@node1:~$ timedatectl | head -4
               Local time: Wed 2026-10-21 14:56:56 MSK
           Universal time: Wed 2026-10-21 11:56:56 UTC
                 RTC time: Wed 2026-10-21 11:56:56
                Time zone: Europe/Moscow (MSK, +0300)

The zone changes only how the time is shown: the system clock runs in UTC, and /etc/localtime becomes a link to /usr/share/zoneinfo/Europe/Moscow. The /etc/timezone file stays as it was (Etc/UTC) — check the zone with timedatectl.

chrony instead of timesyncd

Installing chrony removes systemd-timesyncd. After that set-ntp stops and starts chrony, and timesync-status answers Failed to query server — chronyc tracking shows the state.

Troubleshooting

5

The time has "drifted", logs/certificates look wrong

timedatectl → System clock synchronized: no. Enable NTP: sudo timedatectl set-ntp true; check systemctl status systemd-timesyncd and NTP reachability (chronyc sources or port 123/udp outbound — see firewall).

Failed to set time: Automatic time synchronization is enabled

Turn off auto-sync first: sudo timedatectl set-ntp false, then set the time. Turn it back on after the experiment: sudo timedatectl set-ntp true.

Different times in logs and date

Logs are often in UTC, while date is in the local zone. Cross-check with timedatectl (shows both) or date -u. The journal is in the local zone: journalctl already accounts for TZ.

The clock "jumps" after a reboot

The RTC is in the wrong mode (set-local-rtc). On a Linux server, keep the RTC in UTC (set-local-rtc 0).

Wrong zone inside a container

The host's time zone is not the container's; it's set via the TZ variable or by mounting /etc/localtime.

Terms

2
UTC
Coordinated Universal Time — with no time zones or clock changes. The kernel keeps time in UTC (seconds since 1970); the time zone affects only how it is shown. Also appears in: Cron, journalctl, chrony: time synchronization over NTP, date and 1 more
time zone
The rule for showing time: the offset from UTC and clock changes. The machine's zone is the /etc/localtime link to a file in /usr/share/zoneinfo, changed with timedatectl set-timezone. Also appears in: Cron, chrony: time synchronization over NTP, rsync, systemd timers

See also

  • chrony — an NTP client and server: tracking, sources, clock steps.
  • date — show and set the time, Unix time.
  • systemd — The init system and service manager (PID 1): units, targets, dependencies, journals.
  • journalctl — Reading the systemd journal (journald) — filters by service, time, priority.
Loading…