SnapOverflow

SnapOverflow Logo SnapOverflow Logo

SnapOverflow Navigation

  • Home
  • Server
  • Ubuntu

Mobile menu

Close
  • Home
  • System Administrators
    • Hot Questions
    • New Questions
    • Tags
  • Ubuntu
    • Hot Questions
    • New Questions
    • Tags
  • Help
Home / server / Questions / 822678
Accepted
Diomidis Spinellis
Diomidis Spinellis
Asked: 2016-12-26 12:44:20 +0800 CST2016-12-26 12:44:20 +0800 CST 2016-12-26 12:44:20 +0800 CST

How do I configure a Unix system to run on TAI time?

  • 772

I want to configure a Unix system to run on International Atomic Time (TAI) in order to be able to see the year-end leap second properly reported as 2016-12-31 23:59:60. I know this will cause the system's timestamps to be incompatible with POSIX ones, but I'm doing this as an experiment. I have already copied the timezone file from /usr/share/zoneinfo/right/ to /etc/localtime. These are my questions.

  • How can I accurately set the system's time? I understand that it must be set to TAI seconds, rather than UTC seconds. Is it possible to do this via NTP? Currently, the system displays the time 36 seconds off from the correct one.
  • Will the displayed time continue to be correct after 2017-02-01? Do the zoneinfo/right timezone files need to be updated?
ntp leapsecond
  • 2 2 Answers
  • 1715 Views

2 Answers

  • Voted
  1. John Mahowald
    2016-12-28T06:26:22+08:002016-12-28T06:26:22+08:00

    First, the notion that the clock on a computer system must be provided TAI or UTC is not strictly accurate. I can get and set the time with time zones, for example GNU coreutils date command is very flexible. On a system set to right/UTC (more on this later):

    # date -s "Tue Dec 27 08:16:53 CST 2016"
    Tue Dec 27 14:16:53 UTC 2016
    

    See ESR's essay Time, Clock, and Calendar Programming In C for the actual data structures involved, and some good references.

    You still may configure ntp, ptp, or issue well-timed date or chronyc settime command as usual.

    However, you need to understand the TAI - UTC offset and what your source time is. NTP time is standardly UTC, so just setting a "right" zone on a UTC synced system will be off by TAI - 10 - UTC, which is currently 26.

    Instead, some NTP servers can provide GPS or TAI. This plus some leap second hacks will get rid of the leap second error corrected by the kernel or user land time sync. See: "right" tz database (zoneinfo) files and GPS-based NTP

    Beware that 86401 second days is nonstandard and against what POSIX supposedly requires. If setting up NTP servers that do this, they cannot provide time for other systems. It can also result in strange behaviors from applications that depended on a particularly formatted time.

    TZ data will need to updated, twice a year will catch leap seconds. If you patch leap seconds for this reason you will need to do it again. (Very likely you already need to update other software more often than this for various reasons.) There will be additional leap seconds, the Earth's rotation change is a physical necessity. There also is a political necessity of the likely time zone and daylight savings time changes for… less technical reasons.

    Good timing, as the next leap second is 2016 December 31, 23h 59m 60s.
    Red Hat published a good summary of ways to deal with it on Linux if one is using UTC. Note that many sites repeat, smear, or let NTP fix the second of error without needing to show the 61st second. Resolve Leap Second Issues in Red Hat Enterprise Linux

    This all seems like a lot of work to me. I'd rather not see the 61st second, if I could let NTP or the kernel deal with it, via the methods the Red Hat describes.

    • 2
  2. Best Answer
    Diomidis Spinellis
    2017-01-02T13:42:01+08:002017-01-02T13:42:01+08:00

    Timezone files may need to be updated. You can test it by running a command to see the transitions in the installed timezone file. The following example contains a leap-second transition.

    $ zdump -c 2017,2018 -v /etc/localtime /etc/localtime -9223372036854775808 = NULL /etc/localtime -9223372036854689408 = NULL /etc/localtime Sat Dec 31 23:59:60 2016 UT = Sun Jan 1 01:59:60 2017 EET isdst=0 gmtoff=7200 /etc/localtime Sun Jan 1 00:00:00 2017 UT = Sun Jan 1 02:00:00 2017 EET isdst=0 gmtoff=7200 /etc/localtime Sun Mar 26 00:59:59 2017 UT = Sun Mar 26 02:59:59 2017 EET isdst=0 gmtoff=7200 /etc/localtime Sun Mar 26 01:00:00 2017 UT = Sun Mar 26 04:00:00 2017 EEST isdst=1 gmtoff=10800 /etc/localtime Sun Oct 29 00:59:59 2017 UT = Sun Oct 29 03:59:59 2017 EEST isdst=1 gmtoff=10800 /etc/localtime Sun Oct 29 01:00:00 2017 UT = Sun Oct 29 03:00:00 2017 EET isdst=0 gmtoff=7200 /etc/localtime 9223372036854689407 = NULL /etc/localtime 9223372036854775807 = NULL

    If the timezone file needs updating and if no leap-second (/right) timezone file is provided by your operating system distribution, you can set up the timezone file as follows.

    • fetch the timezone distribution from https://www.iana.org/time-zones,
    • configure and install, and
    • set up the correct zone file (which also includes leap second info) with a command such as the following

    sudo cptzdir/etc/zoneinfo-leaps/your-timezone /etc/localtime

    To set the time from an NTP server you can configure and install rdate (openrdate) and then run a command such as sudo rdate -s -c -n 0.gentoo.pool.ntp.org.

    • 0

Sidebar

Stats

  • Questions 681965
  • Answers 980273
  • Best Answers 280204
  • Users 287326
  • Popular
  • Answers
  • Marko Smith

    Can you pass user/pass for HTTP Basic Authentication in URL parameters?

    • 5 Answers
  • Marko Smith

    Ping a Specific Port

    • 18 Answers
  • Marko Smith

    Check if port is open or closed on a Linux server?

    • 7 Answers
  • Marko Smith

    How to automate SSH login with password?

    • 10 Answers
  • Marko Smith

    How do I tell Git for Windows where to find my private RSA key?

    • 30 Answers
  • Marko Smith

    What's the default superuser username/password for postgres after a new install?

    • 5 Answers
  • Marko Smith

    What port does SFTP use?

    • 6 Answers
  • Marko Smith

    Command line to list users in a Windows Active Directory group?

    • 9 Answers
  • Marko Smith

    What is a Pem file and how does it differ from other OpenSSL Generated Key File Formats?

    • 3 Answers
  • Marko Smith

    How to determine if a bash variable is empty?

    • 15 Answers
  • Martin Hope
    Davie Ping a Specific Port 2009-10-09 01:57:50 +0800 CST
  • Martin Hope
    Smudge Our security auditor is an idiot. How do I give him the information he wants? 2011-07-23 14:44:34 +0800 CST
  • Martin Hope
    kernel Can scp copy directories recursively? 2011-04-29 20:24:45 +0800 CST
  • Martin Hope
    Robert ssh returns "Bad owner or permissions on ~/.ssh/config" 2011-03-30 10:15:48 +0800 CST
  • Martin Hope
    Eonil How to automate SSH login with password? 2011-03-02 03:07:12 +0800 CST
  • Martin Hope
    gunwin How do I deal with a compromised server? 2011-01-03 13:31:27 +0800 CST
  • Martin Hope
    Tom Feiner How can I sort du -h output by size 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich What is a Pem file and how does it differ from other OpenSSL Generated Key File Formats? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent How to determine if a bash variable is empty? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus How do you find what process is holding a file open in Windows? 2009-05-01 16:47:16 +0800 CST

Related Questions

Trending Tags

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • Home
  • Questions
    • Hot Questions
    • New Questions
  • Tags
  • Help

Footer

SnapOverflow

About Us

  • About Us
  • Contact Us

Legal Stuff

  • Privacy Policy

Help

© 2022 SOF-TR. All Rights Reserve