I'm trying to simulate the forthcoming leap second so that I can test my application's behaviour around that time, but I'm not convinced I'm setting up the test properly.

On CentOS 7.2.1511 inside an Oracle VirtualBox virtual machine, here's how I set up NTP and start the test:

yum install ntp

echo "server" > /etc/ntp.conf
echo "fudge stratum 10" >> /etc/ntp.conf
echo "leapfile \"/var/ntp/leap-seconds.list\"" >> /etc/ntp.conf

mkdir /var/ntp
wget -P /var/ntp https://www.ietf.org/timezones/data/leap-seconds.list 
setenforce 0  # avoids having to configure SELinux access to the .list

date -s "2016-12-31 23:55" 
service ntpd restart

However, leaving the following command running shows me that there is no time step of any kind:

$ i=0; while true; do echo -n "$i: "; date -u; ((i++)); sleep 1; done
45: Sat 31 Dec 23:59:56 UTC 2016
46: Sat 31 Dec 23:59:57 UTC 2016
47: Sat 31 Dec 23:59:58 UTC 2016
48: Sat 31 Dec 23:59:59 UTC 2016
49: Sun  1 Jan 00:00:00 UTC 2017
50: Sun  1 Jan 00:00:01 UTC 2017
51: Sun  1 Jan 00:00:02 UTC 2017
52: Sun  1 Jan 00:00:03 UTC 2017
53: Sun  1 Jan 00:00:04 UTC 2017

I'm watching the output as it comes, and each line is printed one second after the other.

And (though this is harder to demonstrate) I can't see any evidence of clock slewing in the data files produced by my application; my NTP configuration should be stepping instead of slewing anyway:

$ cat /etc/sysconfig/ntpd

My local refclock NTP server seems to be doing the job to some degree, because the system log says:

Dec 31 23:59:59 localhost ntpd[1871]: 051b 0b leap_event

What am I missing here?

  • can you post the output from ntpq -pcrv please. My production boxes (Centos 6) leap should be armed but not not active. Also which version of the leap file are you using ? – user3788685 Dec 17 '16 at 4:12
  • @user3788685: pastebin.com/jEGNZPzf And the leap file is downloaded straight from IETF.org as you can see from the above steps. – Lightness Races in Orbit Dec 19 '16 at 17:21
  • was there anything in dmesg - you should of got a line like kernel inserting leap second I get both the 60'th second and the log message line when a valid leap is inserted. – user3788685 Dec 20 '16 at 1:19
  • @user3788685: No, not that I can recall. – Lightness Races in Orbit Dec 20 '16 at 1:57
  • FWIW the real leap second did apply correctly on the night of the 31st, AFAICT. – Lightness Races in Orbit Jan 27 '17 at 16:06

I'd like to add this as a comment to grawity's answer but I don't have enough rep. Whilst (s)he is correct that the non-right timezone doesn't take into account the existence of a second called "60" (i.e. you won't see a timestamp 23:59:60), the Linux kernel should still insert a leap second by repeating second 59 twice (see here for more info). So you should be seeing a repeat of the timestamp 23:59:59. I have reproduced what you're seeing, so you're not crazy, but I'm still trying to work out why.

One thing to check is that your local ntp daemon is definitely inserting the leap second pending flag (either by checking the LI=1 in the packet using Wireshark or similar, or using this ntpq command:

ntpq -c 'lassoc' -c "mrv &1 &999 leap,srcadr,stratum"

Look for leap=01. Mine is so investigations still continue...

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.