Page 1 of 1

Time difference between hwclock and date

PostPosted: Tue Feb 25, 2014 10:06 am
by phil_discount
Hello!

is this a problem?
hwclock shows me allways time differences about 0.5s and 1.1s the whole day.

Code: Select all
vicidial2:~ # hwclock
Tue Feb 25 16:55:25 2014  -0.766472 seconds


i've got a cronjob to sync time every 5 minutes
*/5 * * * */etc/init.d/ntp ntptimeset

regards
philip

Re: Time difference between hwclock and date

PostPosted: Tue Feb 25, 2014 12:09 pm
by williamconley
You've been in open source too long. Catch up. LOL

ntp is NOT used in that fashion any more. It is now a service. Each time you "set" the time, you break that services ability to "sync".

ntp.conf is designed to allow configuration of the ntp daemon which syncs on a continuing basis and keeps track of "how far off" in data files and eventually adjusts itself to maintain proper time precisely (even under heavy load).

since hwclock is only used to set the time during startup, and is usually set to the current time at reboot, it's not used during the day by any process directly (except the ntp daemon, which sets the system time and uses its internal offsets to make that perfect). But if you "reset" time every 5 minutes, this process will never actually happen and your system will never sync.

in opensuse, you can also use "yast" to set the servers to which time will sync.

in a cluster you would have only one server (usually the db, but any server will do) check externally and all the other servers will sync to that one. thus all servers in the cluster will have one time. we also use iburst in this situation to speed the sync process.

in short: hwclock is not meant to have the perfect time. it's job is to go at the same speed all day. ntp uses that constant speed and external time servers with perfect time to Calculate perfect time and modify the server time accordingly. so don't mess with the ntp daemon's ability to complete this process

But how do you know if the ntp daemon is "synced"?
Code: Select all
ntpq -p


If a server listed has a + or * in the left column, the server has synced with that external time service. If none have this symbol, it is attempting to sync but has not yet succeeded. This process normally takes more than 5 minutes. If you "reset" time every 5 minutes, it will never succeed. In fact, even if it does succeed all that data will be deleted when you "set" the time.

Re: Time difference between hwclock and date

PostPosted: Tue Feb 25, 2014 12:11 pm
by geoff3dmg
The hardware clock is only used at system startup. It's updated on shutdown. Thus your server will only have time issues if it is offline for a long period of time. If so, the hwclock command will set the system time to a value that cannot be corrected by NTP because it has drifted too far. Thus your server will have an incorrect time set.

Re: Time difference between hwclock and date

PostPosted: Tue Feb 25, 2014 1:01 pm
by phil_discount
perhaps thats the reason why we've got sometimes strange behaviour with vicicidal_agent_log and call disconnects? :-)

i will test it and give feedback

thanks!

Re: Time difference between hwclock and date

PostPosted: Tue Feb 25, 2014 4:22 pm
by phil_discount
the database server sync via ntp (yast) the from the internet.
every cluster- and webserver has also ntp configured but only with the databaseserver as ntp server.

right?

Re: Time difference between hwclock and date

PostPosted: Tue Feb 25, 2014 4:58 pm
by williamconley
correct.

and if you use the iburst keyword, they will sync faster after a reboot.

use the command given below to check for sync between servers and to check that the db server is synced to external servers.

be careful about using "pool" servers as it can be invitation to attack (we use government only)

Re: Time difference between hwclock and date

PostPosted: Tue Feb 25, 2014 6:00 pm
by phil_discount
the database is syncing with internet, but how can i check if the clusterservers are syncing with the database server?
Code: Select all
ka-vici-mysql:~ # ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
+iris.wf-hosting 62.149.0.30      2 u  584 1024  377   18.136    4.859   0.825
*ntp2.m-online.n 212.18.1.106     2 u   75 1024  377   13.109    4.194   0.923
-master.stbuehle 131.188.3.221    2 u  141 1024  377   13.257   -2.593   1.095
+195.50.171.101  145.253.3.52     2 u  682 1024  377    5.786   -1.417   2.332


there's a * in front of the databaseserver. seems to be ok or not?
Code: Select all
ka-vici-dialercluster8:~ # ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*ka-vici-mysql.s 212.18.3.19      3 u    8 1024  377    0.108    1.287   0.415


iburst is activated.

thanks for help!!

UPDATE: i found the command
Code: Select all
ntpdc -c monlist

then i see every cluster and webserver is synced

Re: Time difference between hwclock and date

PostPosted: Tue Feb 25, 2014 11:22 pm
by williamconley
* means sync'd :) as does +

not sure what monlist does, but it does not seem to specify sync'd or not so be careful. :)