#检查和ntp服务端口
nc -uz ntp服务地址 123
#ntp和chrony默认配置文件
/etc/ntp.conf(主配置文件)
/etc/ntp/step-tickers(初始服务器列表(某些系统具备该文件))
/etc/chrony.conf(主配置文件)
/etc/chrony.keys(默认密钥文件)
#做好以下配置就可以自动同步时间(最简化,首次自动同步2-10s,后续1-17分钟自动同步)
1、只要在/etc/ntp.conf或者/etc/chrony.conf配置server ntp服务地址 iburst(注意pool地址不要设置,可能导致冲突失败)
2、开启ntpd服务或者chronyd服务,systemctl start ntpd或者systemctl start chronyd
3、开机自启systemctl enable ntpd或者systemctl enable chronyd
#检查同步情况
ntpq -pn(有*号显示同步成功)
ntpstat(synchronised表示同步成功)
chronyc tracking(有*号显示同步成功)
chronyc sources(有*号显示同步成功)
#手动立即同步
ntpdate -u ntp服务地址
chronyc makestep
****硬件时间(RTC表示硬件时间,通常为utc时间,本地时间等于utc+8h)*****
hwclock -s(硬件时间同步到系统时间)
hwclock -w(系统时间同步到硬件时间,最好不要!)
timedatectl status(查看硬件和系统时间)