On 12/14/2016 02:03 PM, Michael Hirmke wrote:
Hi Istvan,
Hello:
I am interested if this is possible, and how, in openSUSE 13.1 and 13.2 systems:
The computer is mostly offline and is connected to the network for limited periods only (by USB mobile net device). The computer's clock is inaccurate and shows large differences (tens of minutes), which is becoming worse at every bootup. Instead of playing with adjtime etc, I would like the system to synchronize the time automatically with an ntp server when the computer is connected to the network. I am afraid if I turn on ntp daemon, it causes long delays at boot if net connection isn't available.
you could copy the ntpd service file and replace the ntpd start with a script of your own, which checks internet connection in the first place and starts ntpd afterwards.
ntpd has a mod specifically for this ntpd -q
From the man page:
In some cases it may not be practical for ntpd to run continuously. The -q option is intended for this purpose. Setting this option will cause ntpd to exit just after setting the clock for the first time with the configured servers.
If the machine is going to be shut down relativly soon, you wouldn't need to run the daemon. But the best approach might be to run once ntpd with the -q to get the time set correctly, then at some later time, start ntpd normally. Note that you might also need to add the -g option, because if time is off by 1000 seconds or more, ntpd panics and exits.
Or you could just switch off ntpd's startup check for timeservers, leave it running all the time and trigger setting the clock with some command line tool like ntpdate.
According to the man page for ntpdate, Ntpdate will decline to set the computer's clock if ntpd is running. Better to use the ntpd -q option. -- After all is said and done, more is said than done. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org