Use NTP in Ubuntu for time synchronization Settings
- 2020-05-30 21:56:13
NTP is an TCP/IP protocol that synchronizes time over the network. Usually the client requests the current time from the server and sets its clock based on the result.
While this description is fairly simple, implementing this functionality is extremely complex - there are multiple layers of NTP servers, layer 1 NTP servers connected to the atomic clock, and layer 2 and 3 servers responsible for load balancing to handle all requests from the Internet. In addition, the client may be more complex than you think - it must eliminate communication delays and adjust the time without interfering with other processes running on the server. Fortunately, all of this complexity is encapsulated and you don't need to see it.
In Ubuntu, yes
To synchronize the time.
In the latest version of Ubuntu,
Instead of the old one
. By default,
The time will be synchronized immediately when the system is started and checked again by socket later when the network connection is activated.
It will back you up and let you use the previous Settings. This ensures that the two time synchronization services do not conflict with each other, while retaining the original behavior and configuration when you upgrade. But it also means upgrading from an older release
It will still be installed, thus causing the new systemd-based time service to be disabled.
In the latest version of Ubuntu,
The client part. By default
Periodically check and synchronize the time. It also stores the update times locally so that you can step through them when the system restarts.
Sets the current time state and time configuration that can be used
Command to confirm.
timedatectl status Local time: Fri 2016-04-29 06:32:57 UTC Universal time: Fri 2016-04-29 06:32:57 UTC RTC time: Fri 2016-04-29 07:44:02 Time zone: Etc/UTC (UTC, +0000) Network time on: yes NTP synchronized: no RTC in local TZ: no
If NTP is installed, use it instead
To synchronize the time, then
Will be set to
The nameserver used to get the time can be passed
To specify in addition
There are also flexible additional configuration files.
Due to the
The distribution has been deprecated
, the installation is no longer performed by default. If you do, it will set the time of your computer based on Ubuntu's NTP server when the system starts. Then every time a new network interface is started, it will try again to synchronize the time - during which it will slowly offset the time as long as the time difference it covers is not too great. The behavior can be passed
Switch to control.
By default, systemd-based tools follow from
Request time synchronization. Classical based on
The services are basically all used
In the pool
, as well as
, as well as support for IPv6 if needed. If you want to force IPv6, use it
, but this is not the default configuration.
The daemon for ntp
It calculates the time offset of your system's clock and continuously adjusts it so that there are no large corrections to the time difference, for example, resulting in discontinuous logs. This process only costs a small amount of process resources and memory, but is really trivial for a modern server.
To install ntpd, type on the terminal command line:
sudo apt install ntp
Line. The following servers are configured by default:
# Use servers from the NTP Pool Project. Approved by Ubuntu Technical Board # on 2011-02-08 (LP: #104525). See http://www.pool.ntp.org/join.html for # more information. server 0.ubuntu.pool.ntp.org server 1.ubuntu.pool.ntp.org server 2.ubuntu.pool.ntp.org server 3.ubuntu.pool.ntp.org
After you modify the configuration file, you need to reload it
sudo systemctl reload ntp.service
Check the status
To see more information:
# sudo ntpq -p remote refid st t when poll reach delay offset jitter ======================================================== +stratum2-2.NTP. 126.96.36.199 2 u 5 64 377 68.461 -44.274 110.334 +ntp2.m-online.n 188.8.131.52 2 u 5 64 377 54.629 -27.318 78.882 *184.108.40.206 .DCFa. 1 u 10 64 377 83.607 -30.159 68.343 +stratum2-3.NTP. 220.127.116.11 2 u 5 64 357 68.795 -68.168 104.612 +europium.canoni 18.104.22.168 2 u 63 64 337 81.534 -67.968 92.792