[chrony-users] offline keyword only considered during start of chrony

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


Hello,

(new to this mailing list, please apologize any mistake)

I have a computer with some programs, which behave badly if the clock is stepped while they are running. As such, I want to ensure that chrony only steps the clock during the boot process, or during the shutdown process, before/after these programs have been started/stopped. To add to the complexity, the computer does not necessarily have an active internet connection when booting. In that scenario, I simply want to disable the time sync, as it is not meaningful for chrony to try to adjust the time if the computer comes online later, as it can be off by several hours. Ideally, I am looking for the following behavior:

1. PC boots, chrony starts and tries to synchronize the time.
2.a. If chrony succeeds (internet connection is around), step the time.
2.b If chrony fails (no internet connection), give up after a timeout and disable time synchronization
3. the other programs are started.

The sources are simply configured like this (chrony.conf file):
```
pool pool.ntp.org iburst offline
```

For 2), I tried to use the chrony-wait.service file from the nice example in https://github..com/mlichvar/chrony/blob/master/examples/chrony-wait.service, adapting the ExecStart to something like this:

```
ExecStart=bash -c "if /usr/bin/chronyc -h 127.0.0.1,::1 waitsync 60 0.1 0.0 1; then /usr/bin/chronyc makestep; /usr/bin/chronyc online; else /usr/bin/chronyc offline; fi"
```

This seems to work for the boot process: It steps the time if there is an internet connection and sets the sources to online, and runs `chronyc offline` if not. The latter should not even be necessary in my understanding, as the `pool` is already defined as `offline` in the chrony config file (correct?).
Now for the part that is not working as expected: chrony seems to ignore the `offline`, from both, the config file as well as the explicit `chronyc offline` call, in case the internet connection is established at a later stage, i.e. after chrony has been started. Looking at `chronyc activity`, it reports `1 sources with unknown address` before internet connection is established, and jumps to `4 sources online` after establishing the connection. How can I tell chrony to keep these sources offline? 

If I start chrony with an active internet connection, it correctly sets the sources to `offline` in the beginning (info taken from `chronyc activity`), i.e. I need to explicitly set them online with `chronyc online` to tell chrony to make use of them.

Any other suggestion how to achieve the desired behavior? I want to avoid stopping chrony completely, as it also serves as a time server for other computers in the same network. 

Best regards


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