A server with the wrong time causes problems that are hard to trace: TLS certificates look "not yet valid", one-time login codes (TOTP) are rejected, Kerberos and Active Directory logins fail, scheduled jobs run at unexpected hours, and logs from different machines no longer line up. This guide shows how to check the clock on an Ubuntu or Debian server, set the time zone, find out which NTP client is running, configure it, and fix a server that will not sync.
The commands were written for current Ubuntu and Debian releases that use systemd. Package defaults change between releases, so the guide always shows how to check your own server rather than assume.
1. Read the current state with timedatectl
Start with one command:
timedatectl
Typical output looks like this:
Local time: Fri 2026-12-04 09:00:12 UTC
Universal time: Fri 2026-12-04 09:00:12 UTC
RTC time: Fri 2026-12-04 09:00:12
Time zone: Etc/UTC (UTC, +0000)
System clock synchronized: yes
NTP service: active
RTC in local TZ: no
The lines that matter most:
- Time zone: the zone used to show local time. It does not change the real (UTC) time of the clock.
- System clock synchronized:
yesmeans the kernel reports that the clock has been synchronized by an NTP client.nois your first warning sign. - NTP service:
activemeans a time sync service that timedatectl knows about is running.inactivemeans it is installed but turned off.n/ausually means no supported time sync service is installed. - RTC in local TZ: should be
noon a Linux server, meaning the hardware clock is kept in UTC.
You can also compare local and UTC time quickly with date and date -u.
2. Set the time zone
List the available zone names and filter them:
timedatectl list-timezones | grep -i manila
Then set the zone (this needs root):
sudo timedatectl set-timezone Asia/Manila
This points /etc/localtime to the matching file in /usr/share/zoneinfo. Changing the zone does not move the real clock: the UTC time stays the same, only the local display changes.
UTC or local time?
Many administrators keep servers on UTC (sudo timedatectl set-timezone Etc/UTC). UTC has no daylight saving changes, so there are no skipped or repeated hours, and logs from servers in different regions compare directly. If your team prefers local time for cron schedules, that works too, but be consistent across your fleet and remember:
- Cron jobs run according to the system time zone. Restart the cron service after changing the zone so it picks up the change:
sudo systemctl restart cron. - systemd timers can name a zone directly in
OnCalendar=, for exampleOnCalendar=*-*-* 09:00:00 Asia/Manila. - Long-running services may cache the zone they read at start-up. Restart them, or set a
TZenvironment variable for a single application if it needs a different zone from the server.
3. Find out which NTP client you are running
On Ubuntu and Debian you will usually meet one of two NTP clients:
- systemd-timesyncd: a small, client-only SNTP service that is part of systemd. It is fine for most single servers.
- chrony: a full NTP implementation (
chronydplus thechronyctool). It corrects drift more precisely, handles unstable networks and VMs well, can serve time to other machines, and supports NTS (authenticated NTP).
Ubuntu has used systemd-timesyncd by default for many years, and newer Ubuntu releases switched the default to chrony. On Debian, a minimal install may have no time sync service at all. Check what is actually installed and running:
systemctl status systemd-timesyncd --no-pager
systemctl status chrony --no-pager
dpkg -l | grep -E 'systemd-timesyncd|chrony|ntpsec|^ii ntp '
Run only one NTP client. Two clients fighting over the clock cause jumps and confusing results. On Debian and Ubuntu the packages are set up so that installing chrony normally removes systemd-timesyncd.
| systemd-timesyncd | chrony | |
|---|---|---|
| Main config | /etc/systemd/timesyncd.conf plus drop-ins in /etc/systemd/timesyncd.conf.d/ | /etc/chrony/chrony.conf (Debian and Ubuntu path), often with extra sources in /etc/chrony/sources.d/ |
| Status command | timedatectl timesync-status | chronyc tracking and chronyc sources -v |
| Serves time to other hosts | No (client only) | Yes, with an allow directive |
| NTS (authenticated time) | No | Yes |
| Good fit | Simple servers that only need correct time | VMs, unstable networks, internal time servers, stricter accuracy needs |
4. Configure systemd-timesyncd
Turn automatic sync on (this starts the NTP service timedatectl manages):
sudo timedatectl set-ntp true
To choose your own time servers, use a drop-in file instead of editing the main file, so package updates do not overwrite your change:
sudo mkdir -p /etc/systemd/timesyncd.conf.d
sudo nano /etc/systemd/timesyncd.conf.d/local.conf
[Time]
NTP=0.pool.ntp.org 1.pool.ntp.org 2.pool.ntp.org
FallbackNTP=ntp.ubuntu.com
NTP= is a space-separated list of servers to use. FallbackNTP= is used only when no other server is known. Restart the service and check the result:
sudo systemctl restart systemd-timesyncd
timedatectl timesync-status
The timesync-status output shows the server in use, the poll interval, the last measured offset and other details. A small offset (milliseconds) means the clock is healthy. For a machine-readable view, use timedatectl show-timesync.
5. Configure chrony
Install it if it is not there yet:
sudo apt update
sudo apt install chrony
On Debian and Ubuntu the service is called chrony (on Red Hat based systems it is chronyd). The configuration lives in /etc/chrony/chrony.conf. Time sources are defined with server or pool lines, for example:
pool 2.debian.pool.ntp.org iburst
iburst sends a quick burst of requests at start-up so the first sync happens fast. If your config contains a sourcedir /etc/chrony/sources.d line, you can add your own servers in a file such as /etc/chrony/sources.d/local.sources and load them without a restart:
sudo chronyc reload sources
After editing chrony.conf itself, restart the service:
sudo systemctl restart chrony
Check chrony's health
chronyc tracking
chronyc sources -v
In chronyc tracking, look at Reference ID (the source currently used), System time (how far the clock is from NTP time right now) and Leap status, which should be Normal. In chronyc sources -v, the source marked with ^* is the one chrony is synchronized to; ^+ marks good sources that are combined with it, and ^? means a source is not reachable or not yet usable. The -v flag prints a legend that explains every column.
Large offsets: step or slew
chrony normally corrects the clock gradually ("slewing") so that time never jumps backwards under running applications. The Debian and Ubuntu default configuration includes a line like makestep 1 3, which allows chrony to step (jump) the clock if it is more than 1 second off, but only during the first 3 updates after start-up. If a running server has drifted far and you accept a jump, you can force one immediately:
sudo chronyc makestep
Do this in a quiet moment: a sudden jump can upset databases, schedulers and anything that measures time intervals.
6. Troubleshooting a server that will not sync
- "NTP service: n/a": no supported client is installed. Install
systemd-timesyncdorchrony. - "Failed to set time: Automatic time synchronization is enabled": you tried
timedatectl set-timewhile NTP is on. Let NTP fix the clock instead; set the time by hand only for testing, aftersudo timedatectl set-ntp false, and turn it back on afterwards. - Firewall blocks NTP: NTP uses UDP port 123 outbound. NTS key exchange additionally uses TCP port 4460. Check your host firewall and any cloud security group or upstream firewall.
- Sources unreachable: confirm DNS resolves the server names and test with
chronyc sources -vortimedatectl timesync-status. If public pools are blocked in your network, use your organization's internal NTP servers. - Cloud VMs: major providers offer a local time service that is reachable without internet access. For example, AWS documents the Amazon Time Sync Service at
169.254.169.123, and Google Cloud documents its internal metadata server (metadata.google.internal) as the NTP source for Compute Engine VMs. Check your provider's documentation before changing the image defaults. - Check the logs:
journalctl -u systemd-timesyncdorjournalctl -u chronyshow sync attempts and errors. - Hardware clock in local time: if
RTC in local TZsaysyeson a Linux-only server, switch it back to UTC withsudo timedatectl set-local-rtc 0.
7. Quick checklist
timedatectlshows the time zone you intended.System clock synchronized: yesandNTP service: active.- Only one NTP client is installed and running.
- The offset reported by
timedatectl timesync-statusorchronyc trackingis small. - Outbound UDP 123 is allowed (and TCP 4460 if you use NTS).
- Cron and long-running services were restarted after any time zone change.
Correct time is one of those basics that nobody notices until it breaks. A two-minute check after building a server, and a monitoring alert on the clock offset, saves hours of debugging later.
Sources
- systemd manual: timedatectl, timesyncd.conf and systemd-timesyncd.service
- chrony project documentation: chrony.conf and chronyc manuals
- Ubuntu Server documentation: time synchronisation guides
- Debian Wiki: DateTime
- AWS documentation: Set the time reference on your EC2 instance
- Google Cloud documentation: Configure NTP for VMs
