Re: AW: AW: [chrony-users] chrony: Use of RTC trimming together with ntpdate: A Bad Thing ?

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



On Wed, 31 Aug 2011, thomas.schmid@xxxxxxxxx wrote:

Hi Bill,

OK, more explanation is needed:
1) The system *may* have its BIOS battery removed, been put to storage, taken out of storage, has gotten a new
battery and is now starting up with the BIOS (and then system time) off by hours. For this I want to run ntpdate, which
would bring the system time very close to the real time.
You could run chrony with initstepslew some small number and with the remote
server you want to get the time from initstepslew 30 142.103.1.1 says, go to 142.103.1.1
and ask for the time. If the system time is more than 30 sec off, jump the clock to the right
time. If less, slew the clock to the right time. If you wanted you could make that 1 second instead
(or maybe even 0, but I am not sure that will work.)
I understand, but as this happens during bootup, I *need* a way to find out when chronyd's
"initistepslew"  has finished, to allow me to remove the temporary route to the NTP server
(in reality it is a temporary default route).
So the chrony startup script has run, chronyd was started and the bootup continues to start
more services on the system. And I *need* to have this temporary route removed *before*
the routing services of my system are started in the bootup.
Right now I don't see how I could pick the right moment to remove the route; chronyc cannot
be run (no terminal) and I don't want to rely on looking for clues in syslog.


chronyc can be run from a script. The only condition is that you need to feed
it the password to run priviledged commands. You can either hard code it in, or you can grab it.
Here is an example of a script which runs chronyc in logrotate.d/chrony You
can put in any command you want instead of cyclelogs.
You do not need a terminal.





      KEYID=`awk '$1=="commandkey"{print $2}' /etc/chrony.conf`
      PASS=`awk '$1 =="'$KEYID'" && $3=="" {P=$2}END {print P}' /etc/chrony.keys`
      chronyc <<EOF
       password $PASS
       cyclelogs
       quit
EOF

You can use any command instead of "cyclelogs" (I use this in
logrotate.d/chrony to restart the log files after logrotate has rotated the
old ones out. )


But you can then use chronyc to tell the system to set the rtc to the right time.
True.

Again, you can do it in a script.



2) The system now runs for a while, the external network is disconnected, and the system rebooted. At reboot, chrony
rebooted? Why rebooted?
Just bring down the old network and bring up the new.
More explanation: The system is a customer system, installed in a vehicle. A very possible
scenario is this:
- on monday, the vehicle and the router system are fetched from storage, batteries are
put in, cables to the network (a customer intranet) are connected, and the router system
is started up. Here we have the situation that the RTC is bad and we would need a time
step during the bootup process to bring the system close to real time.

? Why would the rtc be bad. RTC are usually run by a small on board battery,
usually soldered into the motherboard and good for 5-10 years.

Anyway, chrony  with the initstepslew directive will step the system clock to
the right time using the time from a given address.



- On monday evening, cables are disconnected, the router system is shut down, the vehicle
moves to another place, and the router system is started up agagin, but the network cables
will be connected only next day. Here we have a good RTC, but no network connectivity yet.

You set it up to read from the rtc first and then to do the initstepslew.


shall use the RTC to set up the system time, as ntpdate will have failed due to the missing network connections.
ntpdate is a one shot thing. It will connect that once, and then stop.
That is my intended use: Use the "one-shot" ntpdate in combination with the "tracking" chrony.

So I want to have it both ways, but would a possible way be:
run ntpdate
if ntpdate == OK
  run chronyd (without '-s')
else
  run chronyd -s
fi
Just run chronyd to do everything you want?
Again the problem is to find out *when* I can remove the temporary default route which
facilitates the access to the NTP servers when using chronyd's "initstepslew".

Whenever. Chrony does a burst measurement from the given site and if the clock
is out by more than the given amount, it steps the time.


Because I have no control about when the RTC contains valid data or not (Battery remove/change).
OK, then do not use the rtc at all.
Hm, I did not want to go that far...

Thanks for the answers,
Thomas Schmid

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


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

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