How to make ntpd timeout when an Internet connection is not available

Thomas Bratt asked:

I am using the following command to synchronise the time on a Oracle Linux 6.5:

ntpd -gq

Unfortunately it does not timeout when an Internet connection is not available. Is this possible or should implement my own timeout mechanism?

My answer:

If you’re on an intermittently connected machine like a laptop, consider using something other than ntpd, such as chrony, which is designed for situations like this. It is available in EPEL for RHEL 6 and is the default NTP client/server in RHEL 7.

To accomplish this, set the offline option on the servers in your chrony.conf file, and then run the chronyc online command whenever you connect to the Internet.

View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.