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

2016-01-12 Thread Hector Oron
Hello,

2016-01-12 17:26 GMT+01:00 Bill Unruh :
> On Tue, 12 Jan 2016, Hector Oron wrote:

>> Hello,
>>
>>  As I read on an old post here:
>>
>> http://listengine.tuxfamily.org/chrony.tuxfamily.org/chrony-users/2014/10/msg4.html
>>
>>  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.
>
>
> This is a sync of your computer's clock to the remote clock. If chrony is
> running then that will occur continuously and transparently and without any
> steps.

If my clock is set to Mon Nov 23 08:22:48 GMT 2015, chrony does not
seem to be fast to bring it to current actual time, therefore a step
is needed, but the requirement is that it cannot step during computer
activity but at shutdown process.


>>  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.

> I really do not know what this means. Obviously you want your clock on your
> computer to keep running while you are using it. You do not want the system
> time stuck on midnight all of the time. That would certainly break
> everything. But if you run chrony while the system is running, your clock
> will not only
> run continuously, but will also not step. Its rate will simply be increased
> or
> decreased until your clock keeps step with the external clock. So you will
> need to be more specific with what you really want.

Of course I want clock to behave as a clock and I expect it to tick,
but I have a hard requirement that it cannot step during computer
activity. In the above case where date is set to Mon Nov 23 08:22:48
GMT 2015, I am trying to force a step at shutdown, so next time
computer gets running, it might have a close enough time to current
actual time.


>>  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
>
>
> What? why would you do that? It is very unclear what problem you are trying
> to
> solve, but this does not seem to be the solution to any problem I can think
> of. Chrony is NOT like ntpdate. It does not steop the clock each time it
> runs.

Miroslav has been of great help to understand what's going on. I am
now testing the following:
* set old time
* reboot machine, expecting NM hooks get source servers online
* wait 17 minutes for chronyd to take measurements
* run makestep

I hope that brings time to current.

Regards,
-- 
 Héctor Orón  -.. . -... .. .- -.   -.. . ...- . .-.. --- .--. . .-.

--
To unsubscribe email chrony-users-requ...@chrony.tuxfamily.org
with "unsubscribe" in the subject.
For help email chrony-users-requ...@chrony.tuxfamily.org
with "help" in the subject.
Trouble?  Email listmas...@chrony.tuxfamily.org.



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

2016-01-12 Thread Hector Oron
Hello,

2016-01-12 14:33 GMT+01:00 Miroslav Lichvar :
> On Tue, Jan 12, 2016 at 01:26:13PM +0100, Hector Oron wrote:

>> > 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 ?S08: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

> How long ago was the clock set to this date? If chronyd hadn't had a
> chance to make new measurements in that interval, the makestep command
> would not fix the offset as chronyd would still think the date is
> correct. It would be useful to see the output from chronyc tracking
> and chronyc sources before the makestep command.

I change time manually for the tests, so we are talking minutes, maybe
1 or maybe 5.
How long does it need chronyd to take measurements? I assume the only
way to force it to do measurements is with the burst command.

>> $ 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

> Interesting. Any chance the sources in the config are specified with
> the offline option and some service script or networking hook switches
> them online after chronyd is started?

I have a Network Manager hook similar to:
  
https://github.com/frugalware/frugalware-current/blob/master/source/network-extra/networkmanager-dispatcher-chrony/10-chrony

The sources are listed under /etc/chrony/chrony.conf with the offline option:
  server 0..pool.ntp.org offline minpoll 8

Regards
-- 
 Héctor Orón  -.. . -... .. .- -.   -.. . ...- . .-.. --- .--. . .-.

--
To unsubscribe email chrony-users-requ...@chrony.tuxfamily.org
with "unsubscribe" in the subject.
For help email chrony-users-requ...@chrony.tuxfamily.org
with "help" in the subject.
Trouble?  Email listmas...@chrony.tuxfamily.org.



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

2016-01-12 Thread Miroslav Lichvar
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?

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.

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.

>   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?

-- 
Miroslav Lichvar

-- 
To unsubscribe email chrony-users-requ...@chrony.tuxfamily.org 
with "unsubscribe" in the subject.
For help email chrony-users-requ...@chrony.tuxfamily.org 
with "help" in the subject.
Trouble?  Email listmas...@chrony.tuxfamily.org.



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

2016-01-12 Thread Bill Unruh



William G. Unruh   |  Canadian Institute for| Tel: +1(604)822-3273
Physics  | Advanced Research  | Fax: +1(604)822-5324
UBC, Vancouver,BC  |   Program in Cosmology | un...@physics.ubc.ca
Canada V6T 1Z1 |  and Gravity   |  www.theory.physics.ubc.ca/

On Tue, 12 Jan 2016, Hector Oron wrote:


Hello,

 As I read on an old post here:
   
http://listengine.tuxfamily.org/chrony.tuxfamily.org/chrony-users/2014/10/msg4.html

 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.


This is a sync of your computer's clock to the remote clock. If chrony is
running then that will occur continuously and transparently and without any
steps. 


 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.


I really do not know what this means. Obviously you want your clock on your
computer to keep running while you are using it. You do not want the system
time stuck on midnight all of the time. That would certainly break everything. 
But if you run chrony while the system is running, your clock will not only

run continuously, but will also not step. Its rate will simply be increased or
decreased until your clock keeps step with the external clock. So you will
need to be more specific with what you really want.



 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


What? why would you do that? It is very unclear what problem you are trying to
solve, but this does not seem to be the solution to any problem I can think
of. Chrony is NOT like ntpdate. It does not steop the clock each time it runs.



correctly without modifying time during machine activity.

 I would like to know if that's best recommended way to do that or if
there are other alternatives I could use.


See above.





--
To unsubscribe email chrony-users-requ...@chrony.tuxfamily.org 
with "unsubscribe" in the subject.
For help email chrony-users-requ...@chrony.tuxfamily.org 
with "help" in the subject.

Trouble?  Email listmas...@chrony.tuxfamily.org.