1.查看时区
[root@localhost /]# date -R Thu, 12 Jul 2018 11:27:52 +0800
+0800表示东八区,这边就不用再设置
时区中的CST表示中国标准时间。
时区相关共享文件在/usr/share/zoneinfo下,中国一般选择/usr/share/zoneinfo/Asia/Shanghai.
如果时区错误要设置,就执行下面命令:
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
2.查看系统时间
[root@localhost etc]# date 2018年 07月 12日 星期四 19:10:14 CST
3.查看硬件时间
[root@localhost etc]# hwclock 2018年07月12日 星期四 19时10分23秒 -0.210599 秒
4.网络同步时间
[root@localhost etc]# yum -y install ntp ntpdate ...... [root@localhost etc]# ntpdate cn.pool.ntp.org 12 Jul 11:19:56 ntpdate[3367]: step time server 85.199.214.101 offset -28374.974285 sec [root@localhost etc]# date 2018年 07月 12日 星期四 11:20:02 CST
先安装ntpdate工具
再设置系统时间与网络时间同步
再次查看时间,就与真实时间一样了
5.将系统时间写入硬件时间
[root@localhost etc]# hwclock -w
6.强制系统时间写入CMOS中防止重启失效
hwclock -w
或clock -w
参考: