Repository

Looks good to me!

User Tools

Site Tools


kb:internet:connectivity:ntp:start

NTP

Changelog

  • 2024-07-30: Init

The typical NTP service is timesyncd (typically run as system-timesyncd under systemd). This does not actually run a full NTP daemon, but an SNTP (simple NTP). From the systemd mailing list:

...focusing only on querying time from one remote server and synchronizing the local clock to it... The daemon saves the current clock to disk every time a new NTP sync has been acquired (and every 60 seconds), and uses this to possibly correct the system clock early at bootup (e.g. when no RTC clock is available)...

For more accurate timekeeping as well as serving NTP, a recommended solution is to use chrony, which comes as a "chronyd" daemon and "chronyc" CLI. Configuration is under /etc/chrony/chrony.conf, with pool and server settings. Restart the chrony service to load configuration.

server 0.sg.pool.ntp.org
server 1.sg.pool.ntp.org
server 2.sg.pool.ntp.org
server 3.sg.pool.ntp.org

Note this is critical if one wants to use TOTP for 2FA.

# timedatectl
      Local time: Wed 2023-09-20 18:05:04 +08
  Universal time: Wed 2023-09-20 10:05:04 UTC
        RTC time: Wed 2023-09-20 10:05:03
       Time zone: Asia/Singapore (+08, +0800)
 Network time on: yes  <-- system clock is being controlled by NTP service
NTP synchronized: yes  <-- NTP service is available and in sync
 RTC in local TZ: no

Enabling NTP via chronyd (for openSUSE 15.6, unnecessary lines hidden):

# No NTP service running
user:~$ timedatectl
               Local time: Wed 2024-11-27 14:36:38 +08
System clock synchronized: no
              NTP service: inactive
 
# Grab NTP service
user:~$ sudo zypper install chrony
user:~$ timedatectl
               Local time: Wed 2024-11-27 14:45:53 +08
System clock synchronized: yes
              NTP service: inactive
 
# Activate clock synchronization to NTP
user:~$ sudo systemctl enable --now chronyd
user:~$ sudo chronyc makestep
200 OK
user:~$ timedatectl
               Local time: Wed 2024-11-27 14:47:04 +08
System clock synchronized: yes
              NTP service: active
kb/internet/connectivity/ntp/start.txt · Last modified: 3 months ago (27 November 2024) by justin