View Single Post
  #58   Report Post  
Posted to uk.d-i-y
Harry Bloomfield[_3_] Harry Bloomfield[_3_] is offline
external usenet poster
 
Posts: 6,766
Default OT accurate time checks?

The Natural Philosopher formulated the question :
Harry Bloomfield wrote:
Tim Watts used his keyboard to write :
And if you install a proper NTP client, it will try to maintain a drift
correction factor between NTP time and the local (kernel software) clock
which improves accuracy between NTP remote queries.


I used to use one back in the 1980's, but a sync every thirty seconds is
more than enough.

I am fairly sure that somwehere in all of this an ntp daemon 'works out' how
much the real time clock is drifting between time server updates and adjusts
the kernel clock periodically In Linux, anyway.


"ntpd uses the adjtime(2) system call to correct the local system time
without causing time jumps. Adjustments of 32ms and greater are logged using
syslog(3). The threshold value is chosen to avoid having local clock drift
thrash the log files. Should ntpd be started with the -d or -v option, all
calls to adjtime(2) will be logged.

After the local clock is synchronized, ntpd adjusts the clock frequency using
the adjfreq(2) system call to compensate for systematic drift."

(man ntpd)

Isnt it wonderful to have an operating system where all this is just DESIGNED
IN from the word go..


PC's actually use two clocks. A battery backed CMOS RTC clock which
maintains the time whilst the system is off. When the PC is turned on,
the data is transferred into memory, where the PC itself then does the
counting to maintain that separate from the hardware clock's time
interrupt driven.

So there are two possibilities for drifting accuracy - the CMOS RTC's
crystal and the CPU's crystal whilst the PC is on and running. A time
sync adjustment has to correct both of these clocks.

I use this VB script to alter the time interval between my PC syncing
itself via the time servers.

You just need to run it once (ever), to make permanent changes to the
sync interval...

'xp_time_sync.vbs - Change the Internet Time Update Interval
'© Doug Knox - revised - 5/10/2002
'This code may be freely distributed/modified
'Downloaded from www.dougknox.com
'Thanks to Gregory Phillips for catching an error when clicking Cancel.

Option Explicit
On Error Resume Next

'Declare variables
Dim WSHShell, p1, p2, cn, newtime, mycheck, ev, X, Y

'Set the Windows Script Host Shell and assign values to variables
Set WSHShell = WScript.CreateObject("WScript.Shell")

p1 =
"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Servi ces\W32Time\Config\UpdateInterval"
p2 =
"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Servi ces\W32Time\TimeProviders\NtpClient\SpecialPollInt erval"

'This section writes the correct values to the Registry

ev = WSHShell.RegRead(p2)
ev = ev / 3600

cn = ""

Do While IsNumeric(CN) = False

cn = InputBox("Enter the number of hours"& vbCR & "between Internet
Time updates" & vbCR & vbCR & "The current Setting in hours is: " & ev
& vbCR & vbCR & "The default value is 168 hours (7 days).","Value
Entry","24")

If IsNumeric(cn) = False Then
MsgBox "Please enter a number!",4096,"Error!"
End If

If cn = "" Then
Exit Do
End If

Loop

If cn "" AND cn 0 Then

X = InStr(cn,".")
cn = Left(cn,X+2)

newtime = cn * 3600
WSHShell.RegWrite p1, newtime, "REG_DWORD"
WSHShell.RegWrite p2, newtime, "REG_DWORD"
MsgBox "The Internet Time update interval has been changed." & vbCR &
"Reboot your computer for the change to take effect.",4096,"Finished"

Else

If cn = "" Then
MsgBox "The Internet Time update interval has NOT been
changed.",4096,"Cancelled"
Elseif cn = 0 Then
MsgBox "The Internet Time Update interval has NOT been changed." &
vbCR & "The value must be greater than 0 (zero).",4096,"Cancelled"
End If

End If

--
Regards,
Harry (M1BYT) (L)
http://www.ukradioamateur.co.uk