Ubuntu – How to customize the NTP poll rate

ntp

I'm setting up Ubuntu on an embedded machine that runs over a cellular connection, where we pay per byte. The machine also has no RTC battery, so it starts from a random time every boot.

I'd like to ensure that the time gets synced up when the cellular connection comes available so that log messages, etc have real times, but I also don't want to pay an arm and a leg for NTP traffic.

Can I customize the rate at which NTP updates the time? I'm using openntpd currently, but I'm not wedded to it.

The internet is not necessarily up at boot, so ntupdate and related at startup won't work. And scheduling via cron means waiting for the scheduled task to kick in, whereas I want a time daemon to get a time sync ASAP.

Best Answer

Some of these answers could win the obfuscated ntp configuration contest.

Use the ntp reference implementation and use iburst to set the time quickly upon booting. After that the you can use the minpoll directive to limit how often ntpd queries remote time servers. This will allow you to take advantage of ntpd's clock disciplining and keep the bandwidth down.

minpoll minpoll
maxpoll maxpoll
    These options specify the minimum and maximum poll intervals for NTP 
    messages, in seconds as a power of two. The maximum poll interval 
    defaults to 10 (1024 s), but can be increased by the maxpoll option to 
    an upper limit of 17 (36 h). The minimum poll interval defaults to 6 (64 s), 
    but can be decreased by the minpoll option to a lower limit of 3 (8 s).

Chrony is a good alternative to the ntp reference implementation. Openntpd is not.