linux内核日志时间和date时间不一致,正好相差12小时
发现linux的系统时间和系统日志记录时间不一致
[root@nginx ~]# tail -fn 10 /var/log/messages Sep 19 23:11:47 nginx Keepalived_vrrp[127945]: Sending gratuitous ARP on eth1 for 192.168.100.100 Sep 19 23:11:47 nginx Keepalived_vrrp[127945]: Sending gratuitous ARP on eth1 for 192.168.100.100 Sep 19 23:44:50 nginx Keepalived[127942]: Stopping Sep 19 23:44:50 nginx Keepalived_vrrp[127945]: (VI_1) sent 0 priority Sep 19 23:44:50 nginx Keepalived_vrrp[127945]: (VI_1) removing protocol VIPs. Sep 19 23:44:50 nginx Keepalived_healthcheckers[127944]: Shutting down service [192.168.33.18]:tcp:3306 from VS [192.168.100.100]:tcp:3306 Sep 19 23:44:50 nginx Keepalived_healthcheckers[127944]: Stopped Sep 19 23:44:50 nginx kernel: IPVS: __ip_vs_del_service: enter Sep 19 23:44:51 nginx Keepalived_vrrp[127945]: Stopped Sep 19 23:44:51 nginx Keepalived[127942]: Stopped Keepalived v2.0.0 (05/27,2018) ^C [root@nginx ~]# date Fri Sep 20 14:45:06 CST 2019 [root@nginx ~]#
查找原因为:我的date时间是ntp自动同步的,log时间是有rsyslog进程控制的。
解决:service rsyslog restart 或者 /etc/init.d/rsyslog restart,执行之后时间正常
[root@nginx ~]# tail -fn 10 /var/log/messages Sep 19 23:44:50 nginx Keepalived_vrrp[127945]: (VI_1) removing protocol VIPs. Sep 19 23:44:50 nginx Keepalived_healthcheckers[127944]: Shutting down service [192.168.33.18]:tcp:3306 from VS [192.168.100.100]:tcp:3306 Sep 19 23:44:50 nginx Keepalived_healthcheckers[127944]: Stopped Sep 19 23:44:50 nginx kernel: IPVS: __ip_vs_del_service: enter Sep 19 23:44:51 nginx Keepalived_vrrp[127945]: Stopped Sep 19 23:44:51 nginx Keepalived[127942]: Stopped Keepalived v2.0.0 (05/27,2018) Sep 19 23:49:32 nginx kernel: Kernel logging (proc) stopped. Sep 19 23:49:32 nginx rsyslogd: [origin software="rsyslogd" swVersion="5.8.10" x-pid="1969" x-info="http://www.rsyslog.com"] exiting on signal 15. Sep 20 14:49:32 nginx kernel: imklog 5.8.10, log source = /proc/kmsg started. Sep 20 14:49:32 nginx rsyslogd: [origin software="rsyslogd" swVersion="5.8.10" x-pid="130486" x-info="http://www.rsyslog.com"] start ^C [root@nginx ~]# date Fri Sep 20 14:53:38 CST 2019 [root@nginx ~]#