51工具盒子

依楼听风雨
笑看云卷云舒,淡观潮起潮落

Centos7系统日志时间与系统时间不一致

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

解决思路

查看时区是否异常
[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
赞(1)
未经允许不得转载:工具盒子 » Centos7系统日志时间与系统时间不一致