填坑:服务器与CST时间误差8小时的修复方法

1 确认时区是否为shanghai

[root@xxx ~]# ll /etc/localtime
lrwxrwxrwx 1 root root 35 Jul 27  2018 /etc/localtime -> ../usr/share/zoneinfo/Asia/Shanghai

如果不正确,手动修改时区:
[root@xxx ~]# timedatectl set-timezone Asia/Shanghai
或者:
[root@xxx ~]# ln -sf /usr/share/zoneinfo/Universal /etc/localtime

2 检查本地时间与硬件时间

[root@xxx ~]# timedatectl
      Local time: Fri 2018-07-27 00:54:04 CST    本地时间为CST
  Universal time: Thu 2018-07-26 16:54:04 UTC    UTC时间
        RTC time: Thu 2018-07-26 16:54:04        硬件时间默认使用UTC时间
       Time zone: Asia/Shanghai (CST, +0800)
     NTP enabled: yes
NTP synchronized: no
 RTC in local TZ: no
      DST active: n/a

3 修改本地时间

[root@xxx ~]# date -s '-8hour'
Thu Jul 26 16:54:30 CST 2018

4 将本地时间写入硬件时间并重新检查

[root@xxx ~]# hwclock -w
[root@xxx ~]# timedatectl
      Local time: Thu 2018-07-26 16:55:11 CST
  Universal time: Thu 2018-07-26 08:55:11 UTC
        RTC time: Thu 2018-07-26 08:55:11
       Time zone: Asia/Shanghai (CST, +0800)
     NTP enabled: yes
NTP synchronized: no
 RTC in local TZ: no
      DST active: n/a

参考自:https://blog.csdn.net/RogueStudys/article/details/79867299

猜你喜欢

转载自blog.csdn.net/qq_36937234/article/details/81223994
今日推荐