08 Feb 2012
Posted by niczero under mysql
| Tags: mysql
Comments Off on Time rounded to five minutes in MySQL
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.
SELECT FROM_UNIXTIME(300 * FLOOR( UNIX_TIMESTAMP()/300 ))
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.
19 Jul 2011
Posted by niczero under ntp
| Tags: lag
Comments Off on Check ntp status
Check the daemon’s connectivity
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.