How to make ntpd synchronized immediately after reboot?

e271p314 picture e271p314 · Mar 31, 2014 · Viewed 17.1k times · Source

My application must run on a server with time synchronized. In order to do that I installed ntpd and I check the return value of ntpstat. It appears that it takes a very long time to get a zero return value from ntpstat, especially after reboot. Why does it take ntpd such a long period to get synchronized and how can I make it happen few seconds after reboot?

Answer

alvits picture alvits · Mar 31, 2014

To synchronize ntp immediately after reboot, ntpdate has to run before ntpd.

To do this in systemd, you can run

systemctl -a | grep ntp

to see if ntpdate is enabled. To enable it is just run

systemctl enable ntpdate

For Linuxes that use lsb scripts, you can enable ntpdate via chkconfig.

chkconfig ntpdate on