D&C GLug - Home Page

[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]

Re: [LUG] leap second

 

On Sat, 10 Jan 2015, Simon Avery wrote:

 I think you missed my point. I think Torvalds agrees - this time around,
the leap second isn't going to be an issue for us (as per Daniel's)
question. So b***cks to the scare-mongerers telling us all our website are
going to crash.

Why would they? Can't think why web servers would fall over due to poor
dates - although of course I can't predict what crufty cgi has been written
on every one.

Leap seconds are not new. Neither is British summer time or "Daylight savings" as it's sometimes called elsewhere...

Read comp.risks for the past few decades to see issues virtually every time time changes from winter to summer and back again )-: And that's (usually) one hour - what difference can one second make? Well, lots - and there is lots and lots of poorly written software out there (including one of mine which made it to comp.risks if you can find it :-)

Transactions are now happening with sub-millisecond accuracy - particularly in the financial sectors - a whole second there will make a huge difference - could be the difference between gaining or losing a few million pounds for example...

Dedicated fibre circuits are being installed just to save a millisecond on data going over London - it's that crazy in the fast trading financial markets )-:

Heres a trivial/silly example: You schedule a program to run at midnight. This program pays someone some money. Mignight comes, the program runs, the money moves. One second later at leap second time, it's still midnight, so the program runs again ...

Or, you write a program to run once a day - there are 86,400 seconds in a day, right? What happens the day after when 86,401 seconds have elapsed...

PC clocks are notoriously poor, which is why most folk have ntpdate cronned
once a day, or a full ntp server running to keep things in check.

0 0 * * * /usr/sbin/ntpdate time.nist.gov &>/dev/null

If you have Internet access please use ntp and not ntpdate.

Also the days of time.nist.gov are over. Always better to use the pool servers now if possible, and local ones.

If you have a relatively recent ntp installation, then your /etc/ntp.conf could be as simple as:

# by default act only as a basic NTP client
restrict -4 default nomodify nopeer noquery notrap
restrict -6 default nomodify nopeer noquery notrap
# allow NTP messages from the loopback address, useful for debugging
restrict 127.0.0.1
restrict ::1

pool debian.pool.ntp.org iburst
pool uk.pool.ntp.org     iburst


The pool command will pick a set of servers from the given pool, or you can pick then directly via e.g. 0.uk.pool.ntp.org etc. They use round-robbin DNS to make them select different servers and balance the load.


NTP and NTPDATE don't touch the hardware clock. NTP will actually work out how much the Linux clock drifts (that's the software one that Linux maintains, not the hardware one), so that if you're off the Internet for a period of time it will correct drift.

Typically with Linux (And other *nix in general), the hardware clock is only read once at boot time and used to set Linuxes software clock - and it's written to at shutdown time - the hwclock program which manages it can also calculate and correct for drift of the hardware clock - assuming you have corrected the time read from it via NTP.

So at boot:
  hwclock: hardware clock +/- /etc/adjtime -> software clock
  ntp initialised to jump-start the software clock
  (This used to be ntpdate)

Running:
  ntp updates the system clock and calculates drift.

Shutdown:
  hwclock calculates drift from kernel clock vs. hardware clock, writes
  this to /etc/adjtime and updates /etc/adjtime

If there is no hardware clock, you'd typically install the fake-hwclock program and this sets the Linux time (at boot) to the time of the last shutdown. (and writes the time to a file at shutdown) then hopefully ntp will correct it later... This is how its done on the Raspberry Pi for example.

Also, ntpdate is being deprecated - as NTP can now do the functions of ntpdate - more bloat to NTP rather than a separate dedicated program, but that's progress for you.

FWIW: I have designed a software implemented hardware clock for Linux and once managed to get "timelord" as part of my (sadly unofficial) job title.

Time is an illusion ...

Gordon

--
The Mailing List for the Devon & Cornwall LUG
http://mailman.dclug.org.uk/listinfo/list
FAQ: http://www.dcglug.org.uk/listfaq