Redhat has provided a couple of excellent articles describing the upcoming leap second as well as how to handle it. Here, I want to demonstrate the behavior of a server not running NTP.
Configure system to use the “right” zoneinfo
The test machine is on CentOS 6.6 x64 running on cloud. It has the latest tzdata. I switch the system to the “right” zoneinfo such that a leap second will be introduced.
ln -sf /usr/share/zoneinfo/right/Asia/Hong_Kong /etc/localtime
Observe the insertion
From this experiment, I had to reboot the machine in order for the system to reload the zoneinfo data – unlike what others suggested that glibc will automatically reload tzdata. Then I run a simple Java program to display what happens between 2015-07-01 07:59 and 2015-07-01 08:00. Noticed that the 59th second is repeated once:
2015-07-01 07:59:58.009 2015-07-01 07:59:58.059 2015-07-01 07:59:58.109 2015-07-01 07:59:58.159 2015-07-01 07:59:58.210 2015-07-01 07:59:58.260 2015-07-01 07:59:58.310 2015-07-01 07:59:58.361 2015-07-01 07:59:58.411 2015-07-01 07:59:58.461 2015-07-01 07:59:58.512 2015-07-01 07:59:58.562 2015-07-01 07:59:58.612 2015-07-01 07:59:58.663 2015-07-01 07:59:58.713 2015-07-01 07:59:58.763 2015-07-01 07:59:58.814 2015-07-01 07:59:58.864 2015-07-01 07:59:58.914 2015-07-01 07:59:58.965 2015-07-01 07:59:59.015 2015-07-01 07:59:59.065 2015-07-01 07:59:59.116 2015-07-01 07:59:59.166 2015-07-01 07:59:59.216 2015-07-01 07:59:59.267 2015-07-01 07:59:59.317 2015-07-01 07:59:59.367 2015-07-01 07:59:59.418 2015-07-01 07:59:59.468 2015-07-01 07:59:59.518 2015-07-01 07:59:59.569 2015-07-01 07:59:59.619 2015-07-01 07:59:59.669 2015-07-01 07:59:59.720 2015-07-01 07:59:59.770 2015-07-01 07:59:59.820 2015-07-01 07:59:59.871 2015-07-01 07:59:59.921 2015-07-01 07:59:59.974 2015-07-01 07:59:59.025 2015-07-01 07:59:59.075 2015-07-01 07:59:59.125 2015-07-01 07:59:59.176 2015-07-01 07:59:59.226 2015-07-01 07:59:59.276 2015-07-01 07:59:59.327 2015-07-01 07:59:59.377 2015-07-01 07:59:59.427 2015-07-01 07:59:59.478 2015-07-01 07:59:59.528 2015-07-01 07:59:59.578 2015-07-01 07:59:59.629 2015-07-01 07:59:59.679 2015-07-01 07:59:59.729 2015-07-01 07:59:59.779 2015-07-01 07:59:59.830 2015-07-01 07:59:59.880 2015-07-01 07:59:59.930 2015-07-01 07:59:59.981 2015-07-01 08:00:00.031 2015-07-01 08:00:00.081 2015-07-01 08:00:00.132 2015-07-01 08:00:00.183 2015-07-01 08:00:00.233
So this is how we slow down the computer and let the Earth catch up. To me, this is not the smartest idea. Scientist should tune their atomic clocks and insert several ms every now and then. If the idea is for the atomic clock to be accurate, that’s how the adjustment should be made, not just add 1000ms like this.
The Java program is extremely simple. It prints time every 50ms.
import java.util.*; import java.text.SimpleDateFormat; class TellTime { public static void main(String [] args) throws InterruptedException { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); int clicks=500; while (clicks >= 0) { System.out.println(sdf.format(new Date())); clicks--; Thread.sleep(50); } } }
References from Redhat: