NTP is no longer supported on Centos8. Chrony is simpler and more efficient than NTP time synchronization. Timedatectl is a time client tool on Centos7 + Yum -y install chrony or NDF -y install chrony

Modify the chrony.conf configuration file

vim /etc/chrony.conf
Copy the code
Pool 2.centos.pool.ntp.org iburst
Add server IP to iBurst
server ntp.aliyun.com iburst
# Here the server configuration can be netease Cloud/Tencent cloud/Ali cloud and other time servers
# The ones below can be modified or not
Copy the code

Restart the Chronyd service

systemctl restart chronyd.service
Copy the code

Set the Asia/Shanghai time zone

timedatectl set-timezone Asia/Shanghai
Copy the code

or

rm -rf /etc/localtime
ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
Copy the code

4. Set the boot automatically

# Boot automatically upon startup
systemctl enable chronyd
Copy the code