[daily][linux] dmesg格式里的时间为何不许

咱们能看见dmesg的日志带有时间,用dmesg -T参数html

[root@tong ~]# dmesg -T |tail -n 4 [Tue Jan 21 22:05:11 2020] nginx[7607]: segfault at 8 ip 00007f5323cf77a1 sp 00007fff9ce5e030 error 4 in nginx[7f5323c01000+142000] [Tue Jan 21 22:07:17 2020] nginx[12710]: segfault at 8 ip 00007f5323cf77a1 sp 00007fff9ce5e010 error 4 in nginx[7f5323c01000+142000] [Tue Jan 21 22:10:19 2020] nginx[18345]: segfault at 8 ip 00007f5323cf77a1 sp 00007fff9ce5e030 error 4 in nginx[7f5323c01000+142000] [Tue Jan 21 22:10:57 2020] nginx[26517]: segfault at 8 ip 00007f5323cf77a1 sp 00007fff9ce5e030 error 4 in nginx[7f5323c01000+142000]

 

而后有一天,我发现,这个时间戳是不对的。以下,用混杂模式触发一条日志:nginx

[root@tong ~]# date Tue Jan 21 16:32:23 CST 2020 [root@tong ~]# dmesg -T |tail [Tue Jan 21 22:01:45 2020] device eth0 left promiscuous mode [root@tong ~]# cat /var/log/messages |grep eth0 Jan 21 16:32:21 A04-R068-I136-198-JDCLOUD kernel: device eth0 left promiscuous mode

 

观察三个时间,dmesg里,快了7个半小时。 由于它记录的是系统启动到如今的相对时间。秒数,如原始日志服务器

[root@tong ~]# dmesg |tail -n 4 [40354589.699747] nginx[7607]: segfault at 8 ip 00007f5323cf77a1 sp 00007fff9ce5e030 error 4 in nginx[7f5323c01000+142000] [40354715.335800] nginx[12710]: segfault at 8 ip 00007f5323cf77a1 sp 00007fff9ce5e010 error 4 in nginx[7f5323c01000+142000] [40354897.701943] nginx[18345]: segfault at 8 ip 00007f5323cf77a1 sp 00007fff9ce5e030 error 4 in nginx[7f5323c01000+142000] [40354935.607226] nginx[26517]: segfault at 8 ip 00007f5323cf77a1 sp 00007fff9ce5e030 error 4 in nginx[7f5323c01000+142000]

计算验证一下:url

[root@tong ~]# uptime -s 2018-10-11 20:28:43 [root@tong ~]# date -d '2018-10-11 20:28:43' +%s 1539260923 [root@tong ~]# date +%s 1579596146 [root@tong ~]# expr 1579596146 - 1539260923
40335223 [root@tong ~]# dmesg |tail -n 1 [40354935.607226] nginx[26517]: segfault at 8 ip 00007f5323cf77a1 sp 00007fff9ce5e030 error 4 in nginx[7f5323c01000+142000]

 

由于参考系不一样,因此出现了如上的误差。dmesg里的时间参考CPU的时钟频率(?)。系统时间参考的时候外部时间服务器。spa

也就是说,466多天的运行,使本机的计时与真实时间产生了7个小时30分钟的偏差。 .net

而因为ntp的存在,或手动调整过期间,使系统时间与真实时间保持了一致。日志

 

[classic_tong @ https://www.cnblogs.com/hugetong/p/12222470.html]code

相关文章
相关标签/搜索