在日常巡检中发现系统日志与系统时间不一致问题。

解决思路

查看时区是否异常
[root@46 phase2]# date -R
Mon, 09 Aug 2021 10:24:24 +0800
[root@46 phase2]# timedatectl
      Local time: 一 2021-08-09 10:24:34 CST
  Universal time: 一 2021-08-09 02:24:34 UTC
        RTC time: 一 2021-08-09 02:24:34
       Time zone: Asia/Shanghai (CST, +0800)
     NTP enabled: yes
NTP synchronized: yes
 RTC in local TZ: no
      DST active: n/a

如时区不为+0800则替换配置

ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
系统日志时间不一致

查看/var/log/messages 日志内容发现时间与系统时间不一致

Aug  9 02:06:58 46 dbus-daemon: dbus[991]: [system] Activating via systemd: service name='org.freedesktop.timedate1' unit='dbus-org.freedesktop.timedate1.service'
Aug  9 02:06:58 46 dbus[991]: [system] Activating via systemd: service name='org.freedesktop.timedate1' unit='dbus-org.freedesktop.timedate1.service'
Aug  9 02:06:58 46 systemd: Starting Time & Date Service...
Aug  9 02:06:59 46 dbus[991]: [system] Successfully activated service 'org.freedesktop.timedate1'
Aug  9 02:06:59 46 dbus-daemon: dbus[991]: [system] Successfully activated service 'org.freedesktop.timedate1'
Aug  9 02:06:59 46 systemd-timedated: /etc/localtime should be a symbolic link to a time zone data file in /usr/share/zoneinfo/.
Aug  9 02:06:59 46 systemd: Started Time & Date Service.
Aug  9 02:07:50 46 systemd: Starting Time & Date Service...
Aug  9 02:07:50 46 systemd-timedated: /etc/localtime should be a symbolic link to a time zone data file in /usr/share/zoneinfo/.
Aug  9 02:07:50 46 systemd: Started Time & Date Service.
[root@46 ~]# date
2021年 08月 09日 星期一 10:22:25 CST

重启系统日志服务

systemctl restart rsyslog
END

本文标题:Centos7系统日志时间与系统时间不一致

本文作者:宇宙最帅的男人

本文链接:https://lolicp.com/linux/202227441.html

版权声明:转载或者引用本文内容请注明来源及原作者,本文著作权归作者 (宇宙最帅的男人) 所有。

除非另有说明,本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议

最后修改:2022 年 10 月 17 日
如果觉得我的文章对你有用,请随意赞赏