How to Force Immediate NTP Synchronization with systemd-timesyncd: Configuration and Troubleshooting


2 views

When working with systemd's time synchronization daemon, it's important to understand its default polling behavior. The service typically syncs with NTP servers at these intervals:

  • Initial sync attempt: 16 seconds after service start
  • Normal polling interval: 32 minutes (1920 seconds)
  • After large time discrepancy: immediate retry
# Check current poll interval (in seconds)
$ systemctl show systemd-timesyncd.service -p RuntimeMaxUSec
RuntimeMaxUSec=32min

For urgent cases where you can't wait for the normal polling cycle, use these methods:

# Method 1: Full service restart (recommended)
sudo systemctl restart systemd-timesyncd.service

# Method 2: Trigger sync via dbus (alternative)
sudo busctl call org.freedesktop.timesync1 /org/freedesktop/timesync1 \
org.freedesktop.timesync1 Manager Sync

Always verify the sync operation was successful:

$ timedatectl status
      Local time: Tue 2023-05-16 14:32:18 EDT
  Universal time: Tue 2023-05-16 18:32:18 UTC
        RTC time: Tue 2023-05-16 18:32:18
       Time zone: America/New_York (EDT, -0400)
 Network time on: yes
NTP synchronized: yes
 RTC in local TZ: no

To adjust polling behavior permanently, edit /etc/systemd/timesyncd.conf:

[Time]
# Specify multiple NTP servers
NTP=0.pool.ntp.org 1.pool.ntp.org 2.pool.ntp.org
FallbackNTP=ntp.ubuntu.com

# Adjust poll intervals (in seconds)
PollIntervalMinSec=16
PollIntervalMaxSec=2048

If synchronization fails, check these logs:

# View detailed sync attempts
journalctl -u systemd-timesyncd -f

# Check network connectivity to NTP servers
ntpq -p

For persistent issues, consider these solutions:

# Ensure the service is properly enabled
sudo systemctl enable --now systemd-timesyncd

# Check firewall rules (NTP uses UDP port 123)
sudo ufw allow ntp

As a last resort when timesyncd won't cooperate:

# Install ntpdate if needed
sudo apt install ntpdate

# Force immediate update
sudo ntpdate -u pool.ntp.org

Remember that frequent manual syncs can impact NTP server performance, so use this sparingly.


When working with systemd's timesyncd service, it's important to understand its default polling interval behavior. Unlike traditional ntpd, timesyncd uses a more conservative approach:

# Default minimum and maximum poll intervals (in seconds)
PollIntervalMinSec=32
PollIntervalMaxSec=2048

These values mean the service won't immediately sync upon restart, but will gradually adjust its polling frequency based on clock drift measurements.

For urgent situations where you need immediate synchronization, you have several options:

# Method 1: Using timedatectl
sudo timedatectl set-ntp false
sudo timedatectl set-ntp true

# Method 2: Full service restart with debug
sudo systemctl stop systemd-timesyncd
sudo systemctl start systemd-timesyncd --no-block --wait

Always verify your changes with these commands:

timedatectl status
systemctl status systemd-timesyncd
journalctl -u systemd-timesyncd -n 50 --no-pager

For environments requiring more frequent syncs, create or modify:

# /etc/systemd/timesyncd.conf.d/override.conf
[Time]
NTP=ca.pool.ntp.org
PollIntervalMinSec=16
PollIntervalMaxSec=1024

Then apply changes with:

sudo systemctl daemon-reload
sudo systemctl restart systemd-timesyncd

If synchronization still fails:

  1. Check firewall rules (UDP port 123)
  2. Verify DNS resolution of your NTP server
  3. Test basic connectivity: nc -uzv ca.pool.ntp.org 123
  4. Consider using multiple NTP servers for redundancy

For critical time-sensitive systems, consider:

# Install chrony as alternative
sudo apt install chrony
sudo systemctl disable systemd-timesyncd
sudo systemctl enable --now chronyd