A leapsecond and Linux

What it is?

A leapsecond is an extra second that gets inserted always the second for midnight to keep our time in line with variations on the rotation of the earth, as wikipedia puts it:

A leap second is a one-second adjustment that is occasionally applied to Coordinated Universal Time (UTC) in order to keep its time of day close to the mean solar time, or UT1. Without such a correction, time reckoned by Earth's rotation drifts away from atomic time because of irregularities in the Earth's rate of rotation. Since this system of correction was implemented in 1972, 25 such leap seconds have been inserted.

When will it happen?

The next leapsecond is planned for today, june 30 2015 at 23:59:60.  The previous one dates back to june 30 2012.

What does it do?

Just the same as the leap day does, it introduces an extra second just before midnight on a predetermined date, a normal day would end like this:

23:59:58
23:59:59
00:00:00

A day with a leapsecond ends like this:

23:59:58
23:59:59
23:59:60
00:00:00

Therefor putting 61 seconds in the last minute of the day and extending the day by 1 second to 86401 seconds (instead of 86400).

What is the problem with that

Well, you will not notice the insertion of an extra second off course, but computers have a hard time when assumptions they make about something being constant (like a specific length) turn out to be false on occasion.  So applications that work with time, specially on a high precision basis, can behave in unexpected ways unless they have been designed to accomodate the leapsecond.  For example, a program with a timer may fire twice at midnight on this specific day.  A program keeping the length of time may be off by a second, which can have a big impact.

How does Linux handle leapseconds?

Unix systems traditionally keep their internal clocks in UTC and as a POSIX OS, Linux does that too.  The Unix implementation of UTC however does not allow for the time 23:59:60, therefor the Linux kernel will step back one second after 00:00:00, which may cause applications to do unexpected things

How do other systems handle it?

OpenBSD smears the leapsecond over a longer period of time, so there is not double second, but the system time is off by at most 1 second for a longer time.  Windows itself ignores the leapsecond and only corrects the clock when synchronized to a timeserver on the next major timesync.  So essentially being out of sync with UTC for a prolonged period of time.

What to do?

Because leapseconds are very rare events, it is hard to prepare for them.  But it is wise to upgrade your systems before  the leapsecond occurs and specially take care of having the latest updates for tzdata and ntp.

Keep your system admins on standby the night that a leapsecond occurs and make sure you have proper monitoring!