我注意到,自从 Ubuntu 内核上次更新以来,操作系统时钟随机跳秒。我注意到,在运行一个简单的 Python 应用程序后,该应用程序显示语句上的时间戳print
不按时间顺序排列。下面是print
我的 Django 应用程序的控制台和时间戳的示例:
[2023-08-28 17:11:00,078: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:01,190: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:02,378: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:03,462: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:04,630: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:05,758: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:07,122: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:08,350: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:09,606: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:10,966: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:10:55,717: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:10:56,938: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:10:58,294: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:10:59,514: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:00,842: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:02,494: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:04,098: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:05,798: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:09,506: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:10,542: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:11,666: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:12,803: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:14,043: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:15,147: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:16,251: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:17,351: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:18,383: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:19,427: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:20,495: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:21,579: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:22,691: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:23,847: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:24,987: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:26,151: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:11,857: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:12,969: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:14,117: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:15,197: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:16,281: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:17,489: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:18,650: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:19,774: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:20,850: WARNING/ForkPoolWorker-1] Contato un secondo
打开“时钟”应用程序还会显示秒数运行,有时更快,有时更慢,有时从某个数字跳到另一个数字。
我的 Ubuntu 服务器用于timedatectl
同步时间。以下是服务器的详细信息:
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04.4 LTS
Release: 22.04
Codename: jammy
Linux lab01 6.5.0-26-generic #26~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue Mar 12 10:22:43 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
我不明白为什么,但时钟跳了很多。就好像它计数得超级快,它发现时间不对,然后跳回来。例如,这是两个date
命令之间有 1 的命令:
lab@lab01:~$ date
Mon Mar 25 02:25:24 PM CET 2024
lab@lab01:~$ date
Mon Mar 25 02:25:03 PM CET 2024
sudo timedatectl timesync-status
显示高抖动和偏移值(数十秒),但我不明白为什么:
Server: 162.159.200.1 (0.pool.ntp.org)
Poll interval: 32s (min: 32s; max 34min 8s)
Leap: normal
Version: 4
Stratum: 3
Reference: A0E080C
Precision: 1us (-25)
Root distance: 9.864ms (max: 5s)
Offset: -22.284696s
Delay: 3.924ms
Jitter: 10.223410s
Packet count: 53
Frequency: +0.000ppm
我还注意到存在一些问题clocksource
:
$ sudo dmesg | grep clocksource
[ 0.026856] clocksource: refined-jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645519600211568 ns
[ 0.100958] clocksource: tsc-early: mask: 0xffffffffffffffff max_cycles: 0x2c9485be866, max_idle_ns: 440795258057 ns
[ 0.106744] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns
[ 0.146577] clocksource: Switched to clocksource tsc-early
[ 1.765438] clocksource: timekeeping watchdog on CPU1: Marking clocksource 'tsc-early' as unstable because the skew is too large:
[ 1.765440] clocksource: 'refined-jiffies' wd_nsec: 512032000 wd_now: fffedc08 wd_last: fffedb88 mask: ffffffff
[ 1.765442] clocksource: 'tsc-early' cs_nsec: 852454992 cs_now: 9bda08539 cs_last: 9207bcdc0 mask: ffffffffffffffff
[ 1.765443] clocksource: Clocksource 'tsc-early' skewed 340422992 ns (340 ms) over watchdog 'refined-jiffies' interval of 512032000 ns (512 ms)
[ 1.765445] clocksource: 'tsc-early' is current clocksource.
[ 1.765448] tsc: Marking TSC unstable due to clocksource watchdog
[ 1.985248] clocksource: Switched to clocksource refined-jiffies
我曾尝试过chrony
工作,但没有成功。目前我的chrony.conf
是:
pool 0.pool.ntp.org burst
sourcedir /run/chrony-dhcp
sourcedir /etc/chrony/sources.d
keyfile /etc/chrony/chrony.keys
driftfile /var/lib/chrony/chrony.drift
ntsdumpdir /var/lib/chrony
logdir /var/log/chrony
maxupdateskew 100.0
rtcsync
makestep 1 -1
maxdistance 12000
我已经添加了maxdistance
尝试解决该问题的内容。
该命令 sudo chronyc sources -v
显示以下内容:
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^? ns2.fibertelecom.it 2 6 3 59 -278.5s[-278.5s] +/- 53ms
^? ns3.fibertelecom.it 3 6 3 59 -277.7s[-277.7s] +/- 38ms
^? ns1.fibertelecom.it 2 6 3 60 -276.1s[-276.1s] +/- 35ms
^? nettuno.ntp.irh.it 2 6 3 60 -276.9s[-276.9s] +/- 11ms
和chronyc tracking
:
Reference ID : 00000000 ()
Stratum : 0
Ref time (UTC) : Thu Jan 01 00:00:00 1970
System time : 0.000000001 seconds fast of NTP time
Last offset : +0.000000000 seconds
RMS offset : 0.000000000 seconds
Frequency : 86.704 ppm fast
Residual freq : +0.000 ppm
Skew : 0.000 ppm
Root delay : 1.000000000 seconds
Root dispersion : 1.000000000 seconds
Update interval : 0.0 seconds
Leap status : Not synchronised
有什么建议么?
对 grub 的一个小修复使其再次工作
在
/etc/default/grub
文件中您必须添加tsc=nowatchdog
到GRUB_CMDLINE_LINUX_DEFAULT
保存并重新启动,它应该可以工作