查看服务器时间发现与当前时间不符
[root@localhost ~]# clock
2020年03月14日 星期六 17时10分15秒 -0.209044 秒
安装ntpdate工具
[root@localhost ~]# yum -y install ntp ntpdate
设置系统时区为上海
[root@localhost ~]# timedatectl set-timezone Asia/Shanghai
设置系统时间与网络时间同步
[root@localhost ~]# ntpdate 2.asia.pool.ntp.org
14 Mar 09:15:49 ntpdate[3160]: adjust time server 211.233.84.186 offset -0.010519 sec
编辑时间配置文件每个2天同步一次
[root@localhost ~]# vi /etc/crontab
# * */48* * * ntpdate 2.asia.pool.ntp.org
将系统时间写入硬件时间
[root@localhost ~]# hwclock --systohc
强制系统时间写入CMOS中防止重启失效
[root@localhost ~]# hwclock -w
设置硬件时间和系统时间一致并校准
[root@localhost ~]# /sbin/hwclock --systohc