Linux Labs

Inside the system: resources, kernel, processes / Stage 11 of 12

Time, time zone and synchronisation

Not running Starting usually ~20 s
Leave the lesson

Step 5 of 7 · on a machine · 8 min

Slewing and stepping

chrony removes a difference in one of two ways: gently or in a single step.

Gently, by slewing: chrony speeds the clock up or slows it down a little until the difference is gone. Time does not jump, and programs that measure intervals stay correct. But the clock only gains a few seconds a minute this way, and seven minutes of difference take almost an hour and a half to go.

A step moves the clock to the right time at once. Time jumps and the logs get a gap, so stepping is usually allowed only at startup. The makestep 1 3 line in the packaged chrony config allows a step when the difference is over a second, during the first three checks after startup. On this machine the line is commented out, and chrony only slews the clock. How a step and slewing look in the journal is in the Wiki. A step on command, at any moment, is sudo chronyc makestep.

Check yourself 1 question

On this machine the makestep line is commented out, and the clock is seven minutes fast. What happens to the difference after sudo systemctl restart chrony?

  • A step at startup is allowed by the makestep line, and it is commented out: after the restart chronyc tracking shows the same hundreds of seconds of difference.

  • The system reads the RTC when the machine boots; a chrony restart leaves it alone: the machine's clock keeps going, and chrony aligns it by the server.

Without makestep chrony does not step even at startup: it checks the server again and adjusts the clock's rate. The difference melts by a few seconds a minute — you can see it in the System time line of chronyc tracking.

A step is needed when the clock has drifted far and slewing cannot be waited for: certificates, tokens and logs compare time between machines, and seven minutes of difference break logins and signature checks. chrony marks a large difference in its log with a System clock wrong by line — it shows when the clock parted ways with the server. After a step the System time line in chronyc tracking is close to zero, and chrony goes on adjusting the clock's rate as usual.

Exercise · do it

Align the clock now

The machine's clock is seven minutes ahead of time.lab.test again, and chrony slews it by a few seconds a minute. Bring the difference from the server under a second right now. chrony must keep running and checking against time.lab.test.

Sign in and start The machine is available after signing in

Goals · 0 of 2

  • Align the clock with the server not done yet
  • Keep chrony checking against time.lab.test not done yet

Step goals

0 of 2
  • Align the clock with the server — not done yet
  • Keep chrony checking against time.lab.test — not done yet
Ubuntu 24.04

Step goals

0 of 2
  • Align the clock with the server — not done yet
  • Keep chrony checking against time.lab.test — not done yet
Loading…