Difference between revisions of "Ntp"

From Linuxintro
imported>ThorstenStaerk
 
(6 intermediate revisions by one other user not shown)
Line 1: Line 1:
 
NTP is the network time protocol. It allows you to fetch the current date/time from an internet time server. You can also use it to provide a network time service.
 
NTP is the network time protocol. It allows you to fetch the current date/time from an internet time server. You can also use it to provide a network time service.
 +
 +
= Synchronize time =
 +
To sync the time with the time server ''pool.ntp.org'' [[find out your distribution]] and use the [[command]]
 +
 +
== for SUSE ==
 +
sntp -P no -r ''ntp.company.com''
 +
 +
== for other distributions ==
 +
sntp -s no ''ntp.company.com''
 +
 +
= Keep time synchronized =
 +
To keep the time synchronized over reboots,
 +
* sync it one time:
 +
sntp -s no pool.ntp.org
 +
* have a file /etc/ntp.conf with one line:
 +
server pool.ntp.org
 +
* start the NTP service:
 +
/etc/init.d/ntp start
 +
* configure the NTP service to start on boot, e.g. for SUSE Linux:
 +
chkconfig ntp on
  
 
= Show time offset from time server =
 
= Show time offset from time server =
  # sntp timeserver.mycompany.com
+
  # sntp ''timeserver.mycompany.com''
  2011 Aug 16 13:59:55.000224 + 0.000137 +/- 0.002426 secs
+
  2014-02-18 10:09:11.391178 (-0100) '''+6.45592''' +/- 0.000427 secs
 +
 
 +
Means that ''timeserver.mycompany.com'' is 6.5 seconds in the future compared to the local clock.
  
 
= Query status =
 
= Query status =
Line 12: Line 34:
 
   
 
   
 
  Checking for network time protocol daemon (NTPD):                    running
 
  Checking for network time protocol daemon (NTPD):                    running
 
= Query time =
 
To query the time from an ntp server, use ntpdate:
 
# ntpdate pool.ntp.org
 
3 Jun 17:11:29 ntpdate[22682]: step time server 212.45.144.59 offset -28908.834558 sec
 
This will show you date and time in your current time zone defined in /etc/localtime
 
  
 
= Configure it =
 
= Configure it =
 
Edit /etc/ntp.conf, add your time server like this:
 
Edit /etc/ntp.conf, add your time server like this:
 
  server ''myserver.domain''
 
  server ''myserver.domain''

Latest revision as of 08:56, 8 June 2015

NTP is the network time protocol. It allows you to fetch the current date/time from an internet time server. You can also use it to provide a network time service.

Synchronize time

To sync the time with the time server pool.ntp.org find out your distribution and use the command

for SUSE

sntp -P no -r ntp.company.com

for other distributions

sntp -s no ntp.company.com

Keep time synchronized

To keep the time synchronized over reboots,

  • sync it one time:
sntp -s no pool.ntp.org 
  • have a file /etc/ntp.conf with one line:
server pool.ntp.org
  • start the NTP service:
/etc/init.d/ntp start
  • configure the NTP service to start on boot, e.g. for SUSE Linux:
chkconfig ntp on

Show time offset from time server

# sntp timeserver.mycompany.com
2014-02-18 10:09:11.391178 (-0100) +6.45592 +/- 0.000427 secs

Means that timeserver.mycompany.com is 6.5 seconds in the future compared to the local clock.

Query status

# /etc/init.d/ntp status
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*timehost1.local .PPS.            1 u  356 1024  377    1.404    0.049   0.154

Checking for network time protocol daemon (NTPD):                    running

Configure it

Edit /etc/ntp.conf, add your time server like this:

server myserver.domain