{"id":5932,"date":"2016-05-14T12:04:48","date_gmt":"2016-05-14T04:04:48","guid":{"rendered":"http:\/\/rmohan.com\/?p=5932"},"modified":"2016-05-14T12:20:07","modified_gmt":"2016-05-14T04:20:07","slug":"chrony-time-synch","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=5932","title":{"rendered":"Chrony  time synch"},"content":{"rendered":"<p>Alternatively, you can install the new Chrony service that is quicker to synchronize clocks in mobile and virtual systems.<\/p>\n<p>Install the Chrony service:<br \/>\n# yum install -y chrony<\/p>\n<p>Activate the Chrony service at boot:<br \/>\n# systemctl enable chronyd<\/p>\n<p>Start the Chrony service:<br \/>\n# systemctl start chronyd<\/p>\n<p>[root@apache2 ~]# yum install chrony -y<br \/>\nLoaded plugins: fastestmirror<br \/>\nLoading mirror speeds from cached hostfile<br \/>\n * base: mirror.vodien.com<br \/>\n * extras: mirror.vodien.com<br \/>\n * updates: mirror.vodien.com<br \/>\nPackage chrony-2.1.1-1.el7.centos.x86_64 already installed and latest version<br \/>\nNothing to do<br \/>\n[root@apache2 ~]# systemctl start  crond.service<br \/>\n[root@apache2 ~]#<br \/>\n[root@apache2 ~]#<br \/>\n[root@apache2 ~]#<br \/>\n[root@apache2 ~]#<br \/>\n[root@apache2 ~]# systemctl status crond.service<br \/>\n? crond.service &#8211; Command Scheduler<br \/>\n   Loaded: loaded (\/usr\/lib\/systemd\/system\/crond.service; enabled; vendor preset: enabled)<br \/>\n   Active: active (running) since Sat 2016-05-14 20:13:14 SGT; 1h 48min ago<br \/>\n Main PID: 848 (crond)<br \/>\n   CGroup: \/system.slice\/crond.service<br \/>\n           ??848 \/usr\/sbin\/crond -n<\/p>\n<p>May 14 20:13:14 apache2.rmohan.com systemd[1]: Started Command Scheduler.<br \/>\nMay 14 20:13:14 apache2.rmohan.com systemd[1]: Starting Command Scheduler&#8230;<br \/>\nMay 14 20:13:14 apache2.rmohan.com crond[848]: (CRON) INFO (RANDOM_DELAY will be scaled with factor 57% if used.)<br \/>\nMay 14 20:13:14 apache2.rmohan.com crond[848]: (CRON) INFO (running with inotify support)<br \/>\nMay 14 22:00:15 apache2.rmohan.com systemd[1]: Started Command Scheduler.<br \/>\n[root@apache2 ~]# systemctl enable  crond.service<br \/>\n[root@apache2 ~]# chr<br \/>\nchronyc  chronyd  chroot   chrt<br \/>\n[root@apache2 ~]# chronyd<br \/>\n[root@apache2 ~]# chrony<br \/>\nchronyc  chronyd<br \/>\n[root@apache2 ~]# chronyc<br \/>\nchrony version 2.1.1<br \/>\nCopyright (C) 1997-2003, 2007, 2009-2015 Richard P. Curnow and others<br \/>\nchrony comes with ABSOLUTELY NO WARRANTY.  This is free software, and<br \/>\nyou are welcome to redistribute it under certain conditions.  See the<br \/>\nGNU General Public License version 2 for details.<\/p>\n<p>chronyc> quit<\/p>\n<p>The Chrony configuration is in the \/etc\/chrony.conf file:<\/p>\n<p>[root@apache2 ~]# cat  \/etc\/chrony.conf<br \/>\n# Use public servers from the pool.ntp.org project.<br \/>\n# Please consider joining the pool (http:\/\/www.pool.ntp.org\/join.html).<br \/>\nserver 0.centos.pool.ntp.org iburst<br \/>\nserver 1.centos.pool.ntp.org iburst<br \/>\nserver 2.centos.pool.ntp.org iburst<br \/>\nserver 3.centos.pool.ntp.org iburst<\/p>\n<p># Ignore stratum in source selection.<br \/>\nstratumweight 0<\/p>\n<p># Record the rate at which the system clock gains\/losses time.<br \/>\ndriftfile \/var\/lib\/chrony\/drift<\/p>\n<p># Enable kernel RTC synchronization.<br \/>\nrtcsync<\/p>\n<p># In first three updates step the system clock instead of slew<br \/>\n# if the adjustment is larger than 10 seconds.<br \/>\nmakestep 10 3<\/p>\n<p># Allow NTP client access from local network.<br \/>\n#allow 192.168\/16<\/p>\n<p># Listen for commands only on localhost.<br \/>\nbindcmdaddress 127.0.0.1<br \/>\nbindcmdaddress ::1<\/p>\n<p># Serve time even if not synchronized to any NTP server.<br \/>\n#local stratum 10<\/p>\n<p>keyfile \/etc\/chrony.keys<\/p>\n<p># Specify the key used as password for chronyc.<br \/>\ncommandkey 1<\/p>\n<p># Generate command key if missing.<br \/>\ngeneratecommandkey<\/p>\n<p># Disable logging of client accesses.<br \/>\nnoclientlog<\/p>\n<p># Send a message to syslog if a clock adjustment is larger than 0.5 seconds.<br \/>\nlogchange 0.5<\/p>\n<p>logdir \/var\/log\/chrony<br \/>\n#log measurements statistics tracking<br \/>\n[root@apache2 ~]#<\/p>\n<p>Note: For basic configuration purpose, only the server directives could need a change to point at a different set of master time servers than the defaults specified.<\/p>\n<p>To get information about the main time reference, type:<\/p>\n<p>#log measurements statistics tracking<br \/>\n[root@apache2 ~]# chronyc tracking<br \/>\nReference ID    : 202.156.0.34 (time2.maxonline.com.sg)<br \/>\nStratum         : 2<br \/>\nRef time (UTC)  : Sat May 14 04:01:50 2016<br \/>\nSystem time     : 0.001108132 seconds fast of NTP time<br \/>\nLast offset     : +0.002678378 seconds<br \/>\nRMS offset      : 0.002678378 seconds<br \/>\nFrequency       : 37.078 ppm fast<br \/>\nResidual freq   : +0.000 ppm<br \/>\nSkew            : 315.347 ppm<br \/>\nRoot delay      : 0.015427 seconds<br \/>\nRoot dispersion : 0.011265 seconds<br \/>\nUpdate interval : 64.9 seconds<br \/>\nLeap status     : Normal<br \/>\n[root@apache2 ~]#<\/p>\n<p>To get equivalent information to the ntpq command, type:<br \/>\n[root@apache2 ~]# chronyc sources -v<br \/>\n210 Number of sources = 4<\/p>\n<p>  .&#8211; Source mode  &#8216;^&#8217; = server, &#8216;=&#8217; = peer, &#8216;#&#8217; = local clock.<br \/>\n \/ .- Source state &#8216;*&#8217; = current synced, &#8216;+&#8217; = combined , &#8216;-&#8216; = not combined,<br \/>\n| \/   &#8216;?&#8217; = unreachable, &#8216;x&#8217; = time may be in error, &#8216;~&#8217; = time too variable.<br \/>\n||                                                 .- xxxx [ yyyy ] +\/- zzzz<br \/>\n||      Reachability register (octal) -.           |  xxxx = adjusted offset,<br \/>\n||      Log2(Polling interval) &#8211;.      |          |  yyyy = measured offset,<br \/>\n||                                \\     |          |  zzzz = estimated error.<br \/>\n||                                 |    |           \\<br \/>\nMS Name\/IP address         Stratum Poll Reach LastRx Last sample<br \/>\n===============================================================================<br \/>\n^- shim.active-apps.net          2   6    37    58    +14ms[  +14ms] +\/-   61ms<br \/>\n^- time1.maxonline.com.sg        1   6    77    64  -2046us[-2046us] +\/- 3682us<br \/>\n^* time2.maxonline.com.sg        1   6    77     4  -1368us[-6926us] +\/- 4931us<br \/>\n^- tor-exit.katzen.me            2   6    77     9  +4244us[+4244us] +\/-   49ms<\/p>\n<p>Time synchronization can also be forced with the below chronyc commands.<\/p>\n<p>[root@apache2 ~]# chronyc -a &#8216;burst 4\/4&#8217;<br \/>\n200 OK<br \/>\n200 OK<br \/>\n[root@apache2 ~]# chronyc -a makestep<br \/>\n200 OK<br \/>\n200 OK<br \/>\n[root@apache2 ~]#<\/p>\n<p>Chronyc can also be used to view detailed NTP specific information as demonstrated below.<br \/>\n[root@apache2 ~]# chronyc tracking<br \/>\nReference ID    : 202.156.0.34 (time2.maxonline.com.sg)<br \/>\nStratum         : 2<br \/>\nRef time (UTC)  : Sat May 14 04:08:53 2016<br \/>\nSystem time     : 0.000000000 seconds slow of NTP time<br \/>\nLast offset     : -0.000051153 seconds<br \/>\nRMS offset      : 0.001930560 seconds<br \/>\nFrequency       : 2.401 ppm slow<br \/>\nResidual freq   : -0.003 ppm<br \/>\nSkew            : 2.714 ppm<br \/>\nRoot delay      : 0.006534 seconds<br \/>\nRoot dispersion : 0.000577 seconds<br \/>\nUpdate interval : 2.1 seconds<br \/>\nLeap status     : Normal<br \/>\n[root@apache2 ~]# date<br \/>\nSat May 14 12:09:54 SGT 2016<\/p>\n<p>We can also view all NTP servers that chronyc is synchronizing with.<br \/>\n[root@apache1 ~]# chronyc sources<br \/>\n210 Number of sources = 4<br \/>\nMS Name\/IP address         Stratum Poll Reach LastRx Last sample<br \/>\n===============================================================================<br \/>\n^+ 103.224.117.98                4   6    17    26  -5985us[-6099us] +\/-  135ms<br \/>\n^+ frontier.innolan.net          2   6    17    26  +2607us[+2478us] +\/-   71ms<br \/>\n^* tor-exit.katzen.me            2   6    17    25   -499us[ -644us] +\/-   57ms<br \/>\n^- gandhari.thirdeye.it          2   6    17    25  +3135us[+3135us] +\/-  364ms<br \/>\n[root@apache1 ~]# chronyc -a &#8216;burst 4\/4&#8217;<\/p>\n<p>Further information on these sources can then be viewed.<br \/>\n[root@centos7 ~]# chronyc sourcestats<\/p>\n<p>[root@apache2 ~]# chronyc sourcestats<br \/>\n210 Number of sources = 4<br \/>\nName\/IP Address            NP  NR  Span  Frequency  Freq Skew  Offset  Std Dev<br \/>\n==============================================================================<br \/>\nshim.active-apps.net       18   9   689     +1.049     15.882  +2220us  4358us<br \/>\ntime1.maxonline.com.sg     12   6   618     +0.582      4.374   +164us   648us<br \/>\ntime2.maxonline.com.sg     16  14   624     -0.487      2.781   -185us   563us<br \/>\ntor-exit.katzen.me         12   7   617     -0.846      9.713  +4003us  1389us<br \/>\n[root@apache2 ~]#<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Alternatively, you can install the new Chrony service that is quicker to synchronize clocks in mobile and virtual systems.<\/p>\n<p>Install the Chrony service: # yum install -y chrony<\/p>\n<p>Activate the Chrony service at boot: # systemctl enable chronyd<\/p>\n<p>Start the Chrony service: # systemctl start chronyd<\/p>\n<p>[root@apache2 ~]# yum install chrony -y Loaded plugins: fastestmirror [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[73],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/5932"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5932"}],"version-history":[{"count":2,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/5932\/revisions"}],"predecessor-version":[{"id":5934,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/5932\/revisions\/5934"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5932"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5932"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5932"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}