[2024-feb-29] Sad news: Eric Layton aka Nocturnal Slacker aka vtel57 passed away on Feb 26th, shortly after hospitalization. He was one of our Wiki's most prominent admins. He will be missed.

Welcome to the Slackware Documentation Project

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
howtos:network_services:ntp [2013/03/01 13:49 (UTC)] – Added an introduction + some explanations + edited some sections kikinovakhowtos:network_services:ntp [2014/02/17 06:35 (UTC)] kikinovak
Line 9: Line 9:
 ===== Introduction ===== ===== Introduction =====
  
-When several users manipulate shared data on different client PCs on a network, it's important that these machines are all synchronized. Unfortunately, the clients' onboard clock isn't sufficiently precise.+When several users manipulate shared data on different client PCs on a network, it's important that these machines are all synchronized. This is especially true if you share files over NFS, or if you use NIS for centralized authentication. You'll get all sorts of weird errors if your clocks are out of sync. Unfortunately, the clients' onboard clocks aren't sufficiently precise.
  
 That's where NTP (//Network Time Protocol//) comes in handy. It allows networked machines to adjust their clocks so as to be perfectly synchronized. A series of public time servers on the Internet allow the reception of the exact time. From this point, we can use NTP in several ways. That's where NTP (//Network Time Protocol//) comes in handy. It allows networked machines to adjust their clocks so as to be perfectly synchronized. A series of public time servers on the Internet allow the reception of the exact time. From this point, we can use NTP in several ways.
Line 154: Line 154:
  
 <note tip>Again, you might have to wait a few minutes before the first synchronization takes place.</note> <note tip>Again, you might have to wait a few minutes before the first synchronization takes place.</note>
 +  
 +===== Monitor the performance of ntpd =====
  
-=== Synchronizing at boot time ===+You will notice that the logfile ''/var/log/ntp.log'' does not contain any information about the actual accuracy of your system clock. If it's important to you, you can log the statistics of time corrections applied by NTP daemon to the system clock. To do this, add the following lines to ''/etc/ntp.conf'':
  
-If instead of using a daemon, all you want to do is to synchronize time once per boot, it is possible to add the command ''ntpd -qg &'' in the bottom of the file ''/etc/rc.d/rc.local''. This will synchronize the time once in the background and will exit and it needs ''/etc/rc.d/rc.ntpd'' to not be an executable+<code> 
-   +statsdir /var/log/ntp/ 
-  ~# cat /etc/rc.d/rc.local +statistics loopstats 
-  #!/bin/sh +filegen loopstats file loops type day link enable 
-  # +</code> 
-  # /etc/rc.d/rc.local:  Local system initialization script+ 
-  # +You have to create the statsdir manually. Once the configuration changes are in effect, ''ntpd'' will create files named ''loops.YYYYMMDD'' in that directory. Below is an example line from one of these files: 
-  # Put any local startup commands in here.  Also, if you have +<code> 
-  # anything that needs to be run at shutdown time you can +56690 3950.569 0.001199636 2.297 0.001830770 0.571576 10 
-  # make an /etc/rc.d/rc.local_shutdown script and put those +</code> 
-  # commands in there. + 
-  . +The first and second number are the UTC time (expressed as [[http://en.wikipedia.org/wiki/Julian_day|Modified Julian Date]] and seconds elapsed since midnight)The third and fourth number are the offsets of time (in seconds) and of frequency (in parts per million). The fifth and sixth number are their respective uncertainties. 
-  . + 
-  . +To monitor the performance of ''ntpd'', you can examine the plot of clock offset or frequency offset vstime: 
-  ntpd -qg &+ 
 +<code> 
 +$ awk '{printf("%f %f %f\n", $1+$2/86400, $3, $5)}' /var/log/ntp/loops.* > time 
 +$ awk '{printf("%f %f %f\n", $1+$2/86400, $4, $6)}' /var/log/ntp/loops.* > freq 
 +$ gnuplot 
 +gnuplot> set xzeroaxis 
 +gnuplot> plot 'time' with yerror 
 +gnuplot> plot 'freq' with yerror 
 +</code> 
 + 
 +Given enough data, visual examination of the plots will allow you to see peculiarities in ''ntpd'' performance, should they ariseFor example, in the case illustrated by [[http://www.astro.uni.wroc.pl/ludzie/drobek/ntp_time+freq.png|this figure]], the rapid decrease of the frequency offset was caused by replacing the power supply unit of the machine.
  
 ====== Sources ====== ====== Sources ======
  
   * Originally written by [[wiki:user:kikinovak|Niki Kovacs]]   * Originally written by [[wiki:user:kikinovak|Niki Kovacs]]
 +  * Performance monitoring section contributed by Dominik Drobek
  
 <!-- Please do not modify anything below, except adding new tags.--> <!-- Please do not modify anything below, except adding new tags.-->
 <!-- You must remove the tag-word "template" below before saving your new page --> <!-- You must remove the tag-word "template" below before saving your new page -->
 {{tag>howtos time clock synchronization author_kikinovak}} {{tag>howtos time clock synchronization author_kikinovak}}
 howtos:network_services:ntp ()