[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

相關文章
相關標籤/搜索