Re: [chrony-users] Best way to force clock step at shutdown

[ Thread Index | Date Index | More chrony.tuxfamily.org/chrony-users Archives ]


Hello,

2016-01-12 13:05 GMT+01:00 Miroslav Lichvar <mlichvar@xxxxxxxxxx>:
> On Tue, Jan 12, 2016 at 11:58:30AM +0100, Hector Oron wrote:

>>   The recommended way to be able to force a sync is to generate a
>> burst and wait 10 sec for measurements to complete, then do the
>> stepping on the clock.
>>
>>   My requirements need to sync time only at shutdown, but time cannot
>> change during machine activity, if I do the burst, sleep, makestep at
>> shutdown it works, but I would prefer to not have to wait.

> You don't want to wait to make the process faster or not wait for some
> arbitrary number of seconds in the script to make it cleaner?

I do not want to wait arbitrary number of seconds in the script and
add 10sec delay at shutdown process if that can be avoided.

> If measurements were made not too long before the shutdown, i.e.
> chronyd knows the current offset and is correcting it by slewing
> you just need to call chronyc -a makestep to force it to step the
> clock.

chronyd is running,
  root      1143  0.0  0.0  97212  2624 ?        S    08:28   0:00
/usr/sbin/chronyd

however calling makestep does not get clock on time:

$ date ; sudo chronyc -a makestep ; date
Mon Nov 23 08:10:55 GMT 2015
200 OK
200 OK
Mon Nov 23 08:10:55 GMT 2015

$ sudo chronyc -a activity
200 OK
200 OK
4 sources online
0 sources offline
0 sources doing burst (return to online)
0 sources doing burst (return to offline)
0 sources with unknown address

> Another possibility is to stop chronyd and start it again with the -q
> option (ntpdate mode) to just step the clock and exit. If the servers
> are specified with the iburst option, chronyd -q should exit in about
> 5 seconds.

$ sudo systemctl stop chrony.service
$ sudo chronyd -q
2015-11-23T08:14:07Z chronyd version 1.30 starting
2015-11-23T08:14:07Z Frequency -0.569 +/- 0.680 ppm read from
/var/lib/chrony/chrony.drift
2015-11-23T08:14:07Z No suitable source for synchronisation
2015-11-23T08:14:07Z chronyd exiting
$ date
Mon Nov 23 08:14:10 GMT 2015
$ sudo systemctl start chrony.service
$ date
Mon Nov 23 08:15:36 GMT 2015
$ sudo chronyc -a makestep
$ date
Tue Jan 12 12:19:12 GMT 2016

This is getting confusing....

$ sudo timedatectl set-time '2015-11-23 08:10:40'
$ sudo systemctl status chrony.service
[..]
Nov 23 08:11:31 linuxos chrony[1335]: chronyd is running and online.
Nov 23 08:11:36 linuxos chronyd[1341]: Selected source 37.120.173.240
Nov 23 08:11:36 linuxos chronyd[1341]: System clock wrong by
4334987.141084 seconds, adjustment started
$ sudo chronyc -a makestep
200 OK
200 OK
$ date
Mon Nov 23 08:11:15 GMT 2015
$ sudo systemctl restart chrony.service
$ sudo chronyc -a makestep
200 OK
200 OK
$ date
Mon Nov 23 08:11:29 GMT 2015
$ sudo chronyc -a makestep
200 OK
200 OK
$ date
Tue Jan 12 12:23:30 GMT 2016


>>   What I am planning to do is to have a systemd unit file that
>> triggers the burst at machine startup, then does the makestep at
>> shutdown, that way I believe clock should only step at shutdown
>> correctly without modifying time during machine activity.

> So the idea is to correct the system clock before shutdown so the RTC
> can be set to it (e.g. by hwclock), and the next time the machine
> boots the system time won't be too far from the true time?

Correct, that is the idea, but the time cannot change during runtime.

-- 
To unsubscribe email chrony-users-request@xxxxxxxxxxxxxxxxxxxx 
with "unsubscribe" in the subject.
For help email chrony-users-request@xxxxxxxxxxxxxxxxxxxx 
with "help" in the subject.
Trouble?  Email listmaster@xxxxxxxxxxxxxxxxxxxx.


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/