一、centos 7
yum -y install ntpdate
ntpdate ntp1.aliyun.com
crontab -e
01 01 * * * /usr/sbin/ntpdate ntp1.aliyun.com
二、centos 8
yum -y install chrony
//注释pool 2.centos.pool.ntp.org iburst
sed -i 's/^pool 2.centos.pool.ntp.org iburst/#&/' /etc/chrony.conf
//添加三个阿里云NTP的服务器
echo -e "server ntp1.aliyun.com iburst\nserver ntp2.aliyun.com iburst\nserver ntp3.aliyun.com iburst" | sudo tee -a /etc/chrony.conf
systemctl restart chronyd
systemctl enable chronyd