Method 1:
# yum install ntp
synchronizes with the time server, as long as one of the following ntpdate is executed successfully
# ntpdate 0.centos.pool.ntp.org
(# ntpdate cn.pool.ntp.org)
# rm /etc/localtime
Set up a soft connection
# ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
View time
# date
If you do not use clock -w to write to cmos, the timing circuit cannot use the new time. After turning it on, the time is still wrong.
# clock -w
Hardware Clock to System Time, set the system time to be consistent with the hardware clock.
Since this action will cause the system to fully update the file access time, it is best to execute it when the system starts.
# clock --hctosys
Method 2:
Right-click the corresponding virtual machine in vmware
, click Settings, select Options
, check Time Synchronization,
and enter the following command in the virtual machine: # sudo cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
Restart the virtual machine: # reboot
Power-on verification: # date