1

I am using ntpdate to update the time. If there is no internet connection or the NTP server is down, ntpdate fails, but ntpdate takes a long time to exit (approximately 20 to 23 seconds). I read the manual of ntpdate and I see -t timeout option.

-t timeout Specify the maximum time waiting for a server response as the value timeout, in seconds and fraction. The value is rounded to a multiple of 0.2 seconds. The default is 1 second, a value suitable for polling across a LAN.

I thought to try this option but it is taking the same amount of time to exit. I thought if we specify timeout then ntpdate will exit within specified seconds. I used the command like this

ntpdate -u -t 10 <ip>

Did anyone try the timeout option in ntpdate?

sachu
  • 11
  • 1
  • If your Internet connection is intermittent or unreliable, consider using an NTP client/server designed for this scenario such as chrony. – Michael Hampton Jul 24 '21 at 16:24

1 Answers1

1
  • ntpdate will exchange information with ntp server at least three times, before setting time on client to trust this ntp server.
  • Therefore, if you add -t 10 option on ntpdate, it may run about 30s.
  • You can add -d option for more information on checking with ntp server.
    # ntpdate -dv -4 time.stdtime.gov.tw
    16 Jul 14:57:36 ntpdate[652]: ntpdate 4.2.8p15@1.3728-o Wed Jun 22 03:15:52 UTC 2022 (1)
    Looking for host time.stdtime.gov.tw and service ntp
    118.163.81.61 reversed to 118-163-81-61.hinet-ip.hinet.net
    host found : 118-163-81-61.hinet-ip.hinet.net
    transmit(118.163.81.61) // first time
    receive(118.163.81.61)
    transmit(118.163.81.61) // second time
    receive(118.163.81.61)
    transmit(118.163.81.61) // third time
    receive(118.163.81.61)
    transmit(118.163.81.61) // fourth time
    receive(118.163.81.61)
    
    server 118.163.81.61, port 123
    stratum 2, precision -25, leap 00, trust 000
    refid [192.168.0.3], root delay 0.000397, root dispersion 0.019592
    reference time:      e67cdd88.16fefc9c  Sat, Jul 16 2022 14:47:36.089
    originate timestamp: e67cdfe7.80de2e29  Sat, Jul 16 2022 14:57:43.503
    transmit timestamp:  e67cdfe7.5e43017f  Sat, Jul 16 2022 14:57:43.368
    filter delay:  0.29337    0.31583    0.28447    0.31200
                ----       ----       ----       ----
    filter offset: -0.003258  -0.024422  -0.004762  -0.008031
                ----       ----       ----       ----
    delay 0.28447, dispersion 0.00401, offset -0.004762
    
    16 Jul 14:57:43 ntpdate[652]: adjust time server 118.163.81.61 offset -0.004762 sec