Getting a quick and dirty NTP sync

Under normal circumstances, this incantation would be very bad practice, but we’re looking for a quick and dirty (and portable) sync here, so just be sure to only use it on a box where you generally don’t care about your clock.

ntpdate will ordinarily take a domain as an argument, but in this case we specify an IP (this ensures we only get a single server, and we can avoid a whole handful of milliseconds performing a DNS reuest [yes that’s a joke]). Here I’m using also known as and is among the oldest and most reliable non-commercial open-access stratum-1 ntp servers in North America. Also, if you’re ever in a pinch and she ain’t working, there’s another either side 🙂

The -u instructs ntpdate to use an unprivileged port which, while unnecessary under ideal circumstances, will help you avoid colliding with whatever NTP daemon might be running on your machine.

The -p 1 instructs ntpdate to use only a single packet to synchronize, which leads to a much higher skew than you’d otherwise have, but since we’re still almost certainly talking well below sub-second accuracy it’s fine for our purposes here, and much faster than permitting the default of 4.

-b forces the time to be adjusted in a single step instead of allowing ntpdate to slew, which would take more time.

Finally, -v and -d increase verbosity and enable debugging respectively (output from which should be limited due to -p 1 and having a single server to talk to) so we can see what’s going on (and of course just to add to the nerdiness factor).