1、使用root权限编辑ntp.conf文件, vi /etc/ntp.conf 下面红色的两个地方加上去,然后保存退出,
statistics loopstats peerstats clockstats
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable
server 127.127.1.0 # Local clock
fudge 127.127.1.0 stratum 12
#server pool.ntp.org iburst
#server tick.stdtime.gov.tw iburst
server ntp1.aliyun.com iburst
# By default, exchange time with everybody, but do not allow configuration.
restrict -4 default kod notrap nomodify nopeer noquery
restrict -6 default kod notrap nomodify nopeer noquery
# Local users may interrogate the ntp server more closely.
这样是加上了默认的ntp上级服务器,但是如果时间差太大,也不能同步。
2、把 ntpdate ntp1.aliyun.com 这操作写入开机项,每次开机自动运行一遍
vi /etc/rc.local 加入下面红色字后保存退出
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
# Workaround for U3 hub
lists=`find /sys/devices/18013200.rtk_dwc3/18020000.dwc3/xhci-hcd.2.auto -name co
for x in $lists; do
echo on > $x
done
ntpdate ntp1.aliyun.com
exit 0