Time on machine constantly out of sync

Muddro

Explorer
Joined
Oct 6, 2014
Messages
59
Not sure whats going on but my server continuously goes out of sync. I haven't replaced my bios battery yet, because I dont think those go out that often, but the server time constantly gets out of whack.

Anyone have some troubleshooting tips? not even sure where to being (other than checking that yes, the default ntp servers are there in the gui, and i am able to ping them from my network no problem).
 

Fredda

Guru
Joined
Jul 9, 2019
Messages
608
Make sure, the ntp server is running. What is the output of ntpq -p?
The ntp daemon will not synchronize if the time is too far off.
Depending on the configuration it will synchronize when being too far off upon start.
 

Muddro

Explorer
Joined
Oct 6, 2014
Messages
59
Woke up this morning and it's about 35 minutes off

Code:
root@freenas:~ # ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
ntp.amnic.net   .GPS.            1 u   60   64  377  144.628  1824671 16278.0
195.21.137.209  195.66.241.10    2 u   35   64  377    2.913  1826043 16004.3
mcpc.ops-netman 242.71.143.169   2 u    2   64  375   12.118  1827917 19631.8
linode227395.st 163.237.218.19   2 u   50   64  377    6.630  1825275 16000.4
 

Fredda

Guru
Joined
Jul 9, 2019
Messages
608
The ntp daemon is not synchronized, otherwise you would see a '+' or '*' in front of the remote server.
Restart the ntp service. If that does not help, stop the ntp service, run ntpdate <server>, start the ntp service.
 

jgreco

Resident Grinch
Joined
May 29, 2011
Messages
18,680
Sounds like a not-too-unusual PC issue. See past discussions, for example:


Without more specific information on your hardware platform, it's hard to identify what the issue might be. Please note that the forum rules, conveniently linked at the top of every page in red, do request that you post detailed information about your hardware platform. It's very helpful.
 

Muddro

Explorer
Joined
Oct 6, 2014
Messages
59
The ntp daemon is not synchronized, otherwise you would see a '+' or '*' in front of the remote server.
Restart the ntp service. If that does not help, stop the ntp service, run ntpdate <server>, start the ntp service.

Service would not start but able to do the manual update. I've done that before and it just falls out of sync over time again.

Code:
root@freenas:~ # ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 ntp.amnic.net   .GPS.            1 u   30   64  377  144.544  2023021 16108.7
 195.21.137.209  195.66.241.10    2 u   13   64  377    3.789  2023953 16104.4
 mcpc.ops-netman 35.73.197.144    2 u   35   64  377   12.237  2022750 16227.3
 linode227395.st 163.237.218.19   2 u   30   64  377    9.060  2023076 16044.2
root@freenas:~ # service ntp restart
ntp does not exist in /etc/rc.d or the local startup
directories (/etc/ix.rc.d /usr/local/etc/rc.d), or is not executable
root@freenas:~ # ntpdate -u 1.freebsd.pool.ntp.org
 7 Jan 08:15:17 ntpdate[17742]: step time server 208.67.72.50 offset 2028.105796 sec
Broadcast Message from root@freenas.local
        (no tty) at 8:15 EST...

Communications with UPS UPS lost


Broadcast Message from root@freenas.local
        (no tty) at 8:15 EST...

Communications with UPS UPS established


root@freenas:~ # ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 ntp.amnic.net   .GPS.            1 u   18   64  377  144.935  2060.62 2013780
 195.21.137.209  195.66.241.10    2 u    1   64  377    3.234  2991.77 2013766
 mcpc.ops-netman 35.73.197.144    2 u  36m   64  374   12.237  2022750 16227.3
 linode227395.st 163.237.218.19   2 u   15   64  377    6.528  2224.50 2013656
 

Muddro

Explorer
Joined
Oct 6, 2014
Messages
59
Sounds like a not-too-unusual PC issue. See past discussions, for example:


Without more specific information on your hardware platform, it's hard to identify what the issue might be. Please note that the forum rules, conveniently linked at the top of every page in red, do request that you post detailed information about your hardware platform. It's very helpful.
Sorry, using 11.2-u7
  • Motherboard make and model - whatever comes with a ts140
  • CPU make and model - Intel(R) Xeon(R) CPU E3-1276 v3 @ 3.60GHz (8 cores)
  • RAM quantity - 32gb ecc
  • Hard drives, quantity, model numbers, and RAID configuration, including boot drives - 1 pool, 2 vdevs. Vdev1= 4x8tb wdreds, vdev2=4x3tb wdreds (slowly add bigger drives to this one)
  • Hard disk controllers - hba 9207-8i
  • Network cards - motherboard nic
 

jgreco

Resident Grinch
Joined
May 29, 2011
Messages
18,680
So what happens when you follow the general steps outlined in the thread I linked?
 

Fredda

Guru
Joined
Jul 9, 2019
Messages
608
Code:
root@freenas:~ # service ntp restart
ntp does not exist in /etc/rc.d or the local startup directories (/etc/ix.rc.d /usr/local/etc/rc.d ), or is not executable
root@freenas:~ # ntpdate -u 1.freebsd.pool.ntp.org
7 Jan 08:15:17 ntpdate[17742]: step time server 208.67.72.50 offset 2028.105796 sec
The ntp service name is ntpd and not ntp. ntpdate does not work while ntp is running.
 

Muddro

Explorer
Joined
Oct 6, 2014
Messages
59
The ntp service name is ntpd and not ntp. ntpdate does not work while ntp is running.
Ok will check later, but basically ntpd was running in top, but when running service ntpd status, it didn't detect it as running. Killed the pid and then started the service. It seems it is continuing to run. Not sure what crashes ntpd. It's happened before. Will reboot when I get home and see if it crashes again.
 

Muddro

Explorer
Joined
Oct 6, 2014
Messages
59
So what happens when you follow the general steps outlined in the thread I linked?
Ok so got home and was able to get back to this. So, the results:

ntpd status was still sunning, and it was off sync by like thirty minutes even though the service was running fine. I checked the sysctl stuff from the thread, but I don't really know what the output means. then I restarted ntpd and time synced again. continued sending ntpd -np a few times, and within minutes it was off sync again (I think this is true because the +s and *s are gone as you can see below in my code). I will reboot now and type in "sysctl -w kern.timecounter.hardware=ACPI-fast" as the other thread suggests and report back on how long it stays synced. Also going to buy a new battery tomorrow as well see if that has anything to do with it. I wouldnt think so though while its booted.

Code:
root@freenas:~ # date
Tue Jan  7 20:20:40 EST 2020
root@freenas:~ # service ntpd status
ntpd is running as pid 99861.
root@freenas:~ # ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
dns1.campus-rv. 62.149.0.30      2 u   42   64  377  112.604  1707593 16050.2
46.175.224.7.ma 193.106.216.30   3 u   16   64  377  120.401  1709032 16239.8
162.159.200.123 10.11.8.211      3 u   48   64  377    3.833  1707319 16334.4
ntp.wdc1.us.lea 130.133.1.10     2 u   12   64  377   10.151  1709300 16053.3
root@freenas:~ # ntpq -np
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
193.106.144.6   62.149.0.30      2 u   20   64  377  115.522  1711274 16136.9
46.175.224.7    193.106.216.30   3 u   61   64  377  120.401  1709032 16239.8
162.159.200.123 10.11.8.211      3 u   26   64  377    3.585  1711001 16367.9
108.59.2.24     130.133.1.10     2 u   57   64  377   10.151  1709300 16053.3
root@freenas:~ # sysctl kern.timecounter.choic
sysctl: unknown oid 'kern.timecounter.choic'
root@freenas:~ # sysctl kern.timecounter.choice
kern.timecounter.choice: ACPI-fast(900) i8254(0) HPET(950) TSC-low(1000) dummy(-1000000)
root@freenas:~ # sysctl kern.timecounter.hardware
kern.timecounter.hardware: TSC-low
root@freenas:~ # service ntpd restart
Stopping ntpd.
Waiting for PIDS: 99861, 99861.
Starting ntpd.
root@freenas:~ # ntpq -np
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*159.203.82.102  54.39.23.64      3 u    6   64    1    3.112  496.251 300.776
+64.22.253.155   204.9.54.119     2 u    6   64    1   40.464  499.977 300.798
+108.61.73.244   128.59.0.245     2 u    8   64    1    4.202  384.397 236.955
root@freenas:~ # ntpq -np
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*159.203.82.102  54.39.23.64      3 u   17   64    1    3.112  496.251 300.776
+64.22.253.155   204.9.54.119     2 u   17   64    1   40.464  499.977 300.798
+108.61.73.244   128.59.0.245     2 u   19   64    1    4.202  384.397 236.955
root@freenas:~ # ntpq -np
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*159.203.82.102  54.39.23.64      3 u   21   64    1    3.112  496.251 300.776
+64.22.253.155   204.9.54.119     2 u   21   64    1   40.464  499.977 300.798
+108.61.73.244   128.59.0.245     2 u   23   64    1    4.202  384.397 236.955
root@freenas:~ # ntpq -np
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*159.203.82.102  54.39.23.64      3 u   22   64    1    3.112  496.251 300.776
+64.22.253.155   204.9.54.119     2 u   22   64    1   40.464  499.977 300.798
+108.61.73.244   128.59.0.245     2 u   24   64    1    4.202  384.397 236.955
root@freenas:~ # ntpq -np
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*159.203.82.102  54.39.23.64      3 u   29   64    1    3.112  496.251 300.776
+64.22.253.155   204.9.54.119     2 u   29   64    1   40.464  499.977 300.798
+108.61.73.244   128.59.0.245     2 u   31   64    1    4.202  384.397 236.955
root@freenas:~ # ntpq -np
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*159.203.82.102  54.39.23.64      3 u   30   64    1    3.112  496.251 300.776
+64.22.253.155   204.9.54.119     2 u   30   64    1   40.464  499.977 300.798
+108.61.73.244   128.59.0.245     2 u   32   64    1    4.202  384.397 236.955
root@freenas:~ # ntpq -np
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*159.203.82.102  54.39.23.64      3 u   31   64    1    3.112  496.251 300.776
+64.22.253.155   204.9.54.119     2 u   31   64    1   40.464  499.977 300.798
+108.61.73.244   128.59.0.245     2 u   33   64    1    4.202  384.397 236.955
root@freenas:~ # ntpq -np
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
159.203.82.102  54.39.23.64      3 u   18   64    3    3.797  5883.72 5318.30
64.22.253.155   204.9.54.119     2 u   18   64    3   41.136  5887.36 5318.25
108.61.73.244   128.59.0.245     2 u   21   64    1    5.321  5715.78 5147.75
root@freenas:~ # ntpq -np
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
159.203.82.102  54.39.23.64      3 u   24   64    3    3.797  5883.72 5318.30
64.22.253.155   204.9.54.119     2 u   24   64    3   41.136  5887.36 5318.25
108.61.73.244   128.59.0.245     2 u   27   64    1    5.321  5715.78 5147.75
root@freenas:~ # ntpq -np
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
159.203.82.102  54.39.23.64      3 u   26   64    3    3.797  5883.72 5318.30
64.22.253.155   204.9.54.119     2 u   26   64    3   41.136  5887.36 5318.25


EDIT: setting sysctl -w kern.timecounter.hardware=ACPI-fast does seem to fix the problem. Will check back in the AM. If this turns out to be the solution, can you tell me three things:

1. What exactly was wrong or what is it this does, just so I can understand?
2. Are there any implications elsewhere by setting this? Like does this effect anything else? and
2. The other thread says this is not persistent. How would I go about making this permanent? - NM, found it in the GUI
 
Last edited:

jgreco

Resident Grinch
Joined
May 29, 2011
Messages
18,680
The battery won't have any significant effect. Time is stepped at system startup. It's better not to have a totally bogus system clock during system boot, because it could be messing up timestamps etc., but this shouldn't be catastrophic.

The PC platform is a disaster. It was designed back in the 8088 days and has evolved continuously from that state by numerous PC manufacturers and CPU designers, each of whom have had their fingers not only in the pie but often grabbing handfuls. As a result, there are multiple potential sources built into your PC, some of which are better than others.

The original RTC chip on the PC is difficult and slow to access, unable to provide precision time of any sort. This is generally only used for bootstrapping the idea of time (and why I say the battery won't have any significant effect).

The HPET system was designed as a replacement for that, but poor design, a lack of mandate, and some other factors have meant that it isn't available on every platform and occasionally unreliably implemented.

The i8254's Programmable Interrupt Timer (PIT) was one of the first alternatives to accessing the RTC chip directly but hasn't been reliably implemented even in the early days when it was discrete hardware.

Starting with the Pentium, the Advanced Programmable Interrupt Controller (APIC) offered a potentially better source of interrupts, yay progress, but in practice there's a bunch of errata that made this a problem to work with in the real world.

The Time Stamp Counter (TSC) is basically an instruction cycle counter local to the CPU. Unfortunately, in this era of multiple CPU cores, that introduces a bunch of challenges, and then it is also affected by stuff such as CPU C-states (idling) or P-states (lower clock) or T-states (thermal throttling), meaning that the count cannot be directly used to drive time. Because different CPU's have different specifics, the art of deriving a consistent data source from TSC is a bit messy. For TSC this is complicated more by potential BIOS settings for power efficiency.

So FreeBSD's method is to pick one that looks okay, and let the user override it through the sysctl kern.timecounter.hardware mechanism if needed.

Your biggest risk in changing this is that you are hitching your wagon to a different and potentially also problematic horse. The upside is that at some time or other, someone was totally dependent on each one of these clock sources for their time, so a lot of effort has been put into making each one as reliable as possible given the caveats. Whether it'll work for you is unknown, of course.
 

Muddro

Explorer
Joined
Oct 6, 2014
Messages
59
The battery won't have any significant effect. Time is stepped at system startup. It's better not to have a totally bogus system clock during system boot, because it could be messing up timestamps etc., but this shouldn't be catastrophic.

The PC platform is a disaster. It was designed back in the 8088 days and has evolved continuously from that state by numerous PC manufacturers and CPU designers, each of whom have had their fingers not only in the pie but often grabbing handfuls. As a result, there are multiple potential sources built into your PC, some of which are better than others.

The original RTC chip on the PC is difficult and slow to access, unable to provide precision time of any sort. This is generally only used for bootstrapping the idea of time (and why I say the battery won't have any significant effect).

The HPET system was designed as a replacement for that, but poor design, a lack of mandate, and some other factors have meant that it isn't available on every platform and occasionally unreliably implemented.

The i8254's Programmable Interrupt Timer (PIT) was one of the first alternatives to accessing the RTC chip directly but hasn't been reliably implemented even in the early days when it was discrete hardware.

Starting with the Pentium, the Advanced Programmable Interrupt Controller (APIC) offered a potentially better source of interrupts, yay progress, but in practice there's a bunch of errata that made this a problem to work with in the real world.

The Time Stamp Counter (TSC) is basically an instruction cycle counter local to the CPU. Unfortunately, in this era of multiple CPU cores, that introduces a bunch of challenges, and then it is also affected by stuff such as CPU C-states (idling) or P-states (lower clock) or T-states (thermal throttling), meaning that the count cannot be directly used to drive time. Because different CPU's have different specifics, the art of deriving a consistent data source from TSC is a bit messy. For TSC this is complicated more by potential BIOS settings for power efficiency.

So FreeBSD's method is to pick one that looks okay, and let the user override it through the sysctl kern.timecounter.hardware mechanism if needed.

Your biggest risk in changing this is that you are hitching your wagon to a different and potentially also problematic horse. The upside is that at some time or other, someone was totally dependent on each one of these clock sources for their time, so a lot of effort has been put into making each one as reliable as possible given the caveats. Whether it'll work for you is unknown, of course.
Awesome explanation. Thank you for taking the time to explain, it's greatly appreciated. I like learning from these wierd errors, and this was just such an occasion.
 
Top