Changes between Version 4 and Version 5 of ntp


Ignore:
Timestamp:
06/16/2017 07:36:10 PM (7 years ago)
Author:
ken@…
Comment:

Rework how to fix ntpd failing to sync - problem now attributed to suspend to RAM.

Legend:

Unmodified
Added
Removed
Modified
  • ntp

    v4 v5  
    4545}}}
    4646
    47 == Fixes if synchronisation fails ==
     47== Fixes if synchronisation fails following frequent suspend to RAM ==
    4848
    49 For a long time the default kernel clocksource has been tsc, but it used to be acpi_pm. On one of my machines, in one kernel release, I lost synchronisation and the log showed:
     49On one of my machines, ntp had lost synchronisation. I initially blamed the tsc clocksource in a particular kernel version, and recommended changing it back to acpi_pm.
     50
     51=== From the initial version of this section: ===
     52
     53On one of my machines, in one kernel release, I lost synchronisation and the log showed:
    5054{{{
    5155frequency error 1726 PPM exceeds tolerance 500 PPM
     
    6670to the bootargs in grub.
    6771
     72=== A better fix (sysvinit) ===
     73
     74I forgot about the problem, until one day when I discovered that my desktop clock was 5 minutes slow. In the end, this appears to be related to frequent suspend to RAM, sometimes for a few days. In early versions of pm-utils (which is what I use for s2ram) there was a script to fix up ntpd - but that was removed long ago, in the belief that the clock would only drift for a maximum of 64 seconds realtime (not drift *by* 64 seconds!) and then ntpd would start to sync it. For systemd the preferred methods are apparently different. Anyway,I've now added the following script as  /usr/lib/pm-utils/sleep.d/48ntpd (mode 755) and things seem to work - using 'ntpq -p' I can sometimes see offsets of several hundred milliseconds (and increasing!) even when the box has sync'd to my local server, but it seems to stay accurate to within a second, and eventually syncs to a few milliseconds.
     75
     76
     77{{{
     78#!/bin/sh
     79# stop ntpd on suspend, fix and start fresh on wakeup
     80
     81. "${PM_FUNCTIONS}"
     82
     83case $1 in
     84    suspend)
     85        /etc/rc.d/init.d/ntpd stop
     86        ;;
     87    resume)
     88        /usr/sbin/ntpd -gq
     89        /etc/rc.d/init.d/ntpd start
     90    *) exit 0 ;;
     91esac
     92exit 0
     93}}}
     94
     95
    6896== When the clock is too far away from the correct time ==
    6997
    70 If ntpd bails out because the clock is too far from the correct time, try stopping ntpd, using
     98If ntpd bails out because the clock is too far from the correct time, try stopping ntpd, then use
    7199{{{
    72100ntpd -gq
    73101}}}
    74 to let it sync, and then restarting ntpd. According to the man page, -g can be used multiple times if the clock is far adrift.
     102to let it sync, and then restart ntpd. According to the man page, -g can be used multiple times if the clock is far adrift.
    75103
    76104