SUSE Support

Here When You Need Us

Leap Second - test cases

This document (7016355) is provided subject to the disclaimer at the end of this document.

Environment

SUSE Linux Enterprise Server 11
SUSE Linux Enterprise Server 12

Situation

In addition to TID#7016150 (Fixes and workaround to avoid issues caused by Leap Second 2015) SUSE has prepared test cases for SLES 11 and SLES 12.

Resolution

Case 1: Servers without NTP configured

This will alternately insert/delete a second on every UTC midnight (note the irregularity on ends of months that have an odd number of days). As a result, the server clock should never be off by more than 1 second. Plus the drift caused by inaccurate hardware, that will no longer be corrected by NTP.

The only thing needed is a cronjob to run "adjtimex -S16" every odd day and "adjtimex -S32" every even day. The exact time when this is run does not matter, the kernel will remember the setting until UTC midnight and then apply it.

Time will be monotonic except for the leap second insertion itself every other day.
SLE12:
systemctl disable ntpd
systemctl stop ntpd
[[ -x /sbin/adjtimex ]] || zypper -n in adjtimex
cat > /etc/cron.d/test-leap-seconds << __EOF
2 0 1-30/2 * * root /sbin/adjtimex -S16
2 0 2-30/2 * * root /sbin/adjtimex -S32
1 0 *      * * root /sbin/adjtimex -S0
__EOF

SLE11:
chkconfig ntp off
rcntp stop
[[ -x /sbin/adjtimex ]] || zypper in util-linux
cat > /etc/cron.d/test-leap-seconds << __EOF
2 0 1-30/2 * * root /sbin/adjtimex -S16
2 0 2-30/2 * * root /sbin/adjtimex -S32
1 0 *      * * root /sbin/adjtimex -S0
__EOF

Case 2: NTP is running on the server

This will stop ntp just before UTC midnight, then run adjtimex and restart ntp just after midnight. NTP will then fix the error caused by the artificially inserted/deleted second and will continue to sync the time throughout the day.
To do this, the following actions need to be run just before/after UTC midnight.

Time will be monotonic except:
- the leap second insertion itself every other day
- the NTP correction after a leap second deletion (1s is bigger than the   default step value of 0.128s)

SLE12:
Note: cron supports the CRON_TZ variable, which makes things simple:

[[ -x /sbin/adjtimex ]] || zypper -n in adjtimex
cat > /etc/cron.d/test-leap-seconds << __EOF
CRON_TZ=UTC
58 23 * * *      root systemctl stop ntpd
1  00 * * *      root systemctl start ntpd
59 23 1-30/2 * * root /sbin/adjtimex -S16
59 23 2-30/2 * * root /sbin/adjtimex -S32
__EOF

SLE11:
Note: CRON_TZ is not supported, so a script has to run every hour at :59 and :01:
[[ -x /sbin/adjtimex ]] || zypper in util-linux
cat > /usr/local/sbin/test-leap-seconds << "__EOF"
#!/bin/bash
H=`date -u +%H`
M=`date -u +%M`
D=`date -u +%j`
if [[ $((10#$D % 2)) -eq 0 ]]; then
    S=32
else
    S=16
fi
if [[ $H -eq 23 ]] && [[ $M -gt 30 ]]; then
    /usr/sbin/rcntp stop
    /sbin/adjtimex -S$S
fi
if [[ $H -eq 0 ]] && [[ $M -lt 30 ]]; then
    /usr/sbin/rcntp start
fi
__EOF
chmod a+x /usr/local/sbin/test-leap-seconds
echo "01,59 * * * *    root  /usr/local/sbin/test-leap-seconds" > /etc/cron.d/test-leap-seconds


Disclaimer

This Support Knowledgebase provides a valuable tool for SUSE customers and parties interested in our products and solutions to acquire information, ideas and learn from one another. Materials are provided for informational, personal or non-commercial use within your organization and are presented "AS IS" WITHOUT WARRANTY OF ANY KIND.

  • Document ID:7016355
  • Creation Date: 26-Mar-2015
  • Modified Date:03-Mar-2020
    • SUSE Linux Enterprise Server

< Back to Support Search

For questions or concerns with the SUSE Knowledgebase please contact: tidfeedback[at]suse.com

tick icon

SUSE Support Forums

Get your questions answered by experienced Sys Ops or interact with other SUSE community experts.

tick icon

Support Resources

Learn how to get the most from the technical support you receive with your SUSE Subscription, Premium Support, Academic Program, or Partner Program.

tick icon

Open an Incident

Open an incident with SUSE Technical Support, manage your subscriptions, download patches, or manage user access.