UnixTimestamp.app

timedatectl set ntp server: Point systemd-timesyncd at Your Own Time Source

If you search for timedatectl set ntp server, here is the answer: timedatectl has no option for choosing a server. You put the server in systemd-timesyncd's config file, restart the service, and then use timedatectl to turn sync on and check that it worked.

Sophie ParkerPublished ยท 7 min read
Linux server syncing its clock over NTP with a chosen time server through a systemd-timesyncd config file
Key takeaways The short version, before the details.
  1. timedatectl set-ntp true only turns time sync on or off. It never sets a server.
  2. Set NTP= and FallbackNTP= in a timesyncd drop-in file, then restart systemd-timesyncd.
  3. Run timedatectl timesync-status to see which server the clock is really using.
  4. If chrony or ntpd replaced timesyncd, set-ntp fails with "NTP not supported". Set the server in that daemon's own config instead.

timedatectl set ntp server in timesyncd.conf

On most systemd distributions, the program that does the syncing is systemd-timesyncd, a small SNTP client. timedatectl is only the remote control. The server list lives in the timesyncd config, so that is the file you edit.

You can edit /etc/systemd/timesyncd.conf directly. A drop-in file is better, because package upgrades leave it alone and it is easy to see later what you changed.

Create a timesyncd drop-in file

Make the drop-in directory and open a new file in it:

sudo mkdir -p /etc/systemd/timesyncd.conf.d
sudo nano /etc/systemd/timesyncd.conf.d/ntp.conf

Add a [Time] section. Replace the placeholders with the hostnames or IP addresses of your own time sources:

[Time]
NTP=YOUR_PRIMARY_SERVER YOUR_SECOND_SERVER
FallbackNTP=YOUR_BACKUP_SERVER
  • NTP= is a space-separated list of the servers you want. timesyncd tries them in order and stays with the first one that answers.
  • FallbackNTP= is used only when no other server is known, either from this file or from the network configuration.
  • An empty assignment such as NTP= clears any list set by an earlier file. This lets a drop-in replace the defaults instead of adding to them.

Restart systemd-timesyncd and turn sync on

timesyncd reads its config only when it starts. Restart it, then make sure sync is switched on:

sudo systemctl restart systemd-timesyncd
sudo timedatectl set-ntp true

Wait a few seconds, then go to the verification step. If you are new to how clients, servers and stratum levels fit together, our guide to NTP time synchronization covers the background.

Firewalls block NTP quietly. NTP uses UDP port 123. If outbound UDP 123 to your server is blocked, timesyncd keeps retrying and the clock never shows as synchronized. Nothing tells you the config is wrong.

On machines managed by systemd-networkd, timesyncd can also pick up servers per network interface, either from NTP= in a .network file or from DHCP. These link servers are combined with the ones in timesyncd.conf, so a server you never configured can still show up.

What does timedatectl set-ntp actually do?

timedatectl set-ntp takes one boolean. true enables and starts the time sync service. false stops and disables it. That is the whole command. It has no argument for a server, a pool or a poll interval.

sudo timedatectl set-ntp true
sudo timedatectl set-ntp false

Many people expect something like timedatectl set-ntp-server, but that subcommand does not exist. The closest one, timedatectl ntp-servers, sets servers for a single network interface, and only when systemd-networkd manages that interface. For a server that applies to the whole machine, the config file is the answer.

Turn sync off on purpose before setting the clock by hand. While sync is active, timedatectl set-time refuses to run.

How to read time date ctl status output

Running timedatectl with no arguments is the same as timedatectl status. Here is what each line tells you:

LineWhat it means
Local timeThe system clock shown in the configured time zone.
Universal timeThe same moment in UTC.
RTC timeThe battery-backed hardware clock on the motherboard.
Time zoneThe IANA zone name, with its abbreviation and UTC offset.
System clock synchronizedyes once the kernel has been told the clock is in sync. Older systemd versions call this line "NTP synchronized".
NTP serviceactive, inactive, or n/a when no supported sync service is installed.
RTC in local TZno means the hardware clock stores UTC, which is the recommended setting on Linux.

If you want to know why a machine has an RTC at all and how it keeps time while powered off, see how the real time clock works.

NTP service: active with System clock synchronized: no is normal for a minute or so after a restart. If it stays that way, timesyncd cannot reach any server. Check the firewall, DNS, and the server names in your drop-in.

How to check which NTP server is in use

timedatectl status never names the server. Ask timesyncd directly:

timedatectl timesync-status

The Server line shows the address and name of the server timesyncd is talking to right now. Other useful lines:

  • Stratum: how far the server is from a reference clock.
  • Offset: how far your clock was from the server at the last poll.
  • Delay and Jitter: round-trip time and how much it varies.
  • Packet count: should rise over time. If it stays at zero, no replies are coming back.

To see every server timesyncd knows about and where each one came from, use the machine-readable view:

timedatectl show-timesync --all

SystemNTPServers lists what you set in the config file, LinkNTPServers what came from the network, and FallbackNTPServers the backup list. If your server is missing from SystemNTPServers, the drop-in was not read. Check the file path, the [Time] header and the .conf extension. For live messages, follow the service log:

journalctl -u systemd-timesyncd -f

Why set-ntp fails with chrony or ntpd installed

timedatectl can only switch on a time sync unit it knows about. If none is available, you get:

Failed to set ntp: NTP not supported

This usually happens in one of two cases:

  • systemd-timesyncd is not installed. On Debian and Ubuntu it is a separate package, and minimal images or containers often leave it out.
  • Another daemon replaced it. Installing chrony or ntpsec on Debian-based systems removes systemd-timesyncd, so timedatectl has nothing to toggle.

The fix depends on what you want. To keep chrony or ntpd, leave timedatectl out of it. Set the server in that daemon's own config and manage it with systemctl. To go back to timesyncd, remove the other daemon, install the systemd-timesyncd package, and repeat the steps above.

Never run two sync daemons at once. They would both try to steer the same clock. Some distributions, Fedora and RHEL among them, register chronyd with timedatectl, so on those systems set-ntp toggles chronyd and the servers are set in chrony's config file.

timedatectl list timezones and set your zone

NTP keeps the clock in UTC. The time zone only changes how that time is displayed. To list every zone name the system knows, narrowed with grep:

timedatectl list-timezones | grep -i europe

Then set the zone by its exact name and check the result:

sudo timedatectl set-timezone Europe/Berlin
timedatectl status
Skip the typingPick a zone from a searchable list and copy the timedatectl commands Open tool

To compare times across zones before you switch, try the timezone converter. For the full option list, the official timedatectl manual, the timesyncd.conf reference and the systemd-timesyncd service page are the sources to trust.

Ready to fix the rest of your Linux clock?

  • Copy timedatectl set-time and hwclock --systohc commands for any date you pick
  • Choose a time zone and get the set-timezone, status and list-timezones commands
  • Build date +FORMAT output and date math with a live preview
Open the Linux date command generator

Frequently asked questions

No. timedatectl set-ntp only takes true or false, so it can switch sync on or off but cannot name a server. Set NTP= and FallbackNTP= in a file under /etc/systemd/timesyncd.conf.d/, restart systemd-timesyncd, and use timedatectl timesync-status to confirm the new server is in use.

From /etc/systemd/timesyncd.conf, the .conf drop-ins in /etc/systemd/timesyncd.conf.d/, and, on systemd-networkd machines, from NTP= in .network files or servers handed out by DHCP. The FallbackNTP= list is used only when none of those sources supplies a server.

timedatectl found no time sync service it can control. Usually systemd-timesyncd is not installed, or installing chrony or ntpsec removed it. Either reinstall systemd-timesyncd, or keep the other daemon, set its servers in its own config file, and manage it with systemctl.

Run timedatectl timesync-status. The Server line shows the address and name timesyncd is polling, along with offset, delay and packet count. timedatectl show-timesync --all lists every configured server and where it came from: the config file, a network link, or the fallback list.

The kernel has not been told the clock is in sync. This is normal right after boot or a restart. If it stays at no, sync may be off (check the NTP service line), the server may be unreachable, or UDP port 123 may be blocked. Read journalctl -u systemd-timesyncd for the reason.