ntp

The Network Time Protocol (NTP) is a networking protocol for clock synchronization between computer systems over packet-switched, variable-latency data networks.[1]

Note that the system has already an NTP server that is "ntp.ubuntu.com".

Verifying NTP

To verify the NTP servers, enter show ntp server in the user mode. If none of the servers exists, it indicates that there are no NTP servers except for the default.

LYSH@MyHostName# show ntp servers

To show the status of the Time synchronization, show ntp status in the user mode. It shows the status of, when, and where the time was synchronized.

LYSH@MyHostName# show ntp status
● systemd-timesyncd.service - Network Time Synchronization
     Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2021-04-27 13:12:30 KST; 10s ago
       Docs: man:systemd-timesyncd.service(8)
   Main PID: 18992 (systemd-timesyn)
     Status: "Connecting to time server [2001:67c:1560:8003::c8]:123 (ntp.ubuntu.com)."
      Tasks: 2 (limit: 9387)
     Memory: 1.6M
     CGroup: /system.slice/systemd-timesyncd.service
             └─18992 /lib/systemd/systemd-timesyncd

You can also verify the Time synchronization by using the show datetime commmand.

LYSH@MyHostName# show datetime
               Local time: Tue 2021-04-27 13:32:46 KST
           Universal time: Tue 2021-04-27 04:32:46 UTC
                 RTC time: Tue 2021-04-27 04:32:46
                Time zone: Asia/Seoul (KST, +0900)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no

add / delete

You can configure the NTP servers. If you add an NTP server, the system synchronizes the time using added NTP server. If the Time synchronization failed from a server, the system tries to the next server.

LYSH@MyHostName# configure
configure# ntp add asia.pool.ntp.org
configure# exit
LYSH@MyHostName# show ntp servers
NTP Servers                   : asia.pool.ntp.org

You can see the status of the time synchronization to a time server by the show ntp status command. If the "Status" shows "Idle", it indicates the system couldn't synchronize to one of the NTP servers.

LYSH@MyHostName# show ntp status
● systemd-timesyncd.service - Network Time Synchronization
     Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2021-04-27 13:10:36 KST; 12s ago
       Docs: man:systemd-timesyncd.service(8)
   Main PID: 18321 (systemd-timesyn)
     Status: "Initial synchronization to time server 157.119.108.165:123 (asia.pool.ntp.org)."
      Tasks: 2 (limit: 9387)
     Memory: 1.6M
     CGroup: /system.slice/systemd-timesyncd.service
             └─18321 /lib/systemd/systemd-timesyncd

To remove one of the NTP servers, enter the ntp delete {ntp-server-name} in the configuration mode.

LYSH@MyHostName# configure
configure# ntp delete asia.pool.ntp.org
configure# exit

enable / disable

You can disable the System clock synchronizing using the NTP server.

LYSH@MyHostName# configure
configure# ntp disable
Local time: Tue 2021-04-27 10:26:03 KST
           Universal time: Tue 2021-04-27 01:26:03 UTC
                 RTC time: Tue 2021-04-27 01:26:03
                Time zone: Asia/Seoul (KST, +0900)
System clock synchronized: no
              NTP service: inactive
          RTC in local TZ: no

You can also enable it. The status of the "System clock synchronized" may show "inactive" for a while after enabling the NTP and the status will be changed to "active" in few seconds.

LYSH@MyHostName# configure
configure# ntp enable
  Local time: Tue 2021-04-27 10:26:03 KST
           Universal time: Tue 2021-04-27 01:26:03 UTC
                 RTC time: Tue 2021-04-27 01:26:03
                Time zone: Asia/Seoul (KST, +0900)
  System clock synchronized: active
              NTP service: active
          RTC in local TZ: no

datetime

To show the system time and date, enter the show datetime command.

LYSH@MyHostName# show datetime
               Local time: Tue 2021-04-27 13:32:46 KST
           Universal time: Tue 2021-04-27 04:32:46 UTC
                 RTC time: Tue 2021-04-27 04:32:46
                Time zone: Asia/Seoul (KST, +0900)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no


To change the system time and date, enter the datetime {format}. The format must be 'yyyy-mm-dd hh24:mi:ss'.
Note that if you manually change the system time and date while the NTP is enabled, you encounter the "Failed to set time: Automatic time synchronization is enabled" error. Therefore you need to disable the NTP before configuring the system time and date manually.

LYSH@MyHostName# configure
configure# datetime 2021-04-27 13:00:00
              Local time: Tue 2021-04-27 13:00:00:49 KST
          Universal time: Tue 2021-04-27 04:00:00 UTC
                RTC time: Tue 2021-04-27 04:00:00
               Time zone: Asia/Seoul (KST, +0900)
System clock synchronized: yes
             NTP service: active
         RTC in local TZ: no

References