Search:
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
pool ntp5.aliyun.com iburst
# Record the rate at which the system clock gains/losses time.
driftfile /var/lib/chrony/drift
# Allow the system clock to be stepped in the first three updates
# if its offset is larger than 1 second.
makestep 1.0 3
# Enable kernel synchronization of the real-time clock (RTC).
rtcsync
# Enable hardware timestamping on all interfaces that support it.
#hwtimestamp *
# Increase the minimum number of selectable sources required to adjust
# the system clock.
#minsources 2
# Allow NTP client access from local network.
#allow 192.168.0.0/16
# Serve time even if not synchronized to a time source.
#local stratum 10
# Specify file containing keys for NTP authentication.
keyfile /etc/chrony.keys
# Get TAI-UTC offset and leap seconds from the system tz database.
leapsectz right/UTC
# Specify directory for log files.
logdir /var/log/chrony
# Select which information is logged.
#log measurements statistics tracking
一般来说,配置文件无需改动就能正常使用。当然为了同步速度快,可以使用国内的ntp服务器,例如将第一行改成:
ntp1.aliyun.com
iburst(公共ntp服务器请参考:
公共 NTP 服务器地址大全
)。
接下来可以手动同步时间:
chronyd -q 'pool ntp1.aliyun.com iburst'
# output
2021-01-20T13:43:30Z chronyd version 3.5 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP +SCFILTER +SIGND +ASYNCDNS +SECHASH +IPV6 +DEBUG)
2021-01-20T13:43:34Z System clock wrong by -0.001392 seconds (step)
2021-01-20T13:43:34Z chronyd exiting
更好的方式是让chronyd后台运行,自动同步时间:
systemctl enable chronyd
systemctl start chronyd