For reporting-style stats we often need to round down ‘now’ to the nearest 5 mins. For instance, my current project requires the code to identify the current ‘rolling twenty minutes’ with such rounding. An easy way to do this that works even in MySQL v4.0 is the following.


which gives the most recently-passed 5-min datetime, taking 13:52:50 down to 13:50:00.
Of course, if you need rounding to the nearest 15 mins then the 300 would be changed to 900.


Check the daemon’s connectivity

ntpq -p

hoping to see an asterisk in the first column for one of the servers listed. If you have recently (re)started the daemon, give it a few minutes to get itself established.

ntpdc -c loopinfo

to check its calculated offset. A value of 0 sec offset indicates it’s still confused.

ntpdc -c kerninfo

to check the error margins don’t look too big.