User Tools

Site Tools


the_ntp_functions

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
the_ntp_functions [2017/03/17 18:34] – [Edit NTP Configuration File] walkeradminthe_ntp_functions [2023/03/09 22:35] (current) – external edit 127.0.0.1
Line 135: Line 135:
 \\  \\ 
  
 +----
 +==== Restart NTP ====
 +\\ 
 +To get the Raspberry Pi to sync, we can restart the NTP service. Use the following to restart the NTP server.
 +\\ 
 +    sudo service ntp restart
 +\\ 
 +\\ 
 +Now check the current time and date using the <color #ed1c24>date</color> command.
 +\\ 
 +    date
 +    
 +    Fri 17 Mar 18:38:59 UTC 2017
 +\\ 
 +If the time and date are correct, then you are good to go.
 +\\ 
 +\\ 
  
 +----
 +==== Check NTP Servers ====
 +\\ 
 +You can test to see if NTP on the Raspberry Pi is actually using any external time servers by using the <color #ed1c24>ntpq -pn</color> command.
 +\\ 
 +<file>
 +ntpq -pn
  
  
 +     remote           refid      st t when poll reach   delay   offset  jitter
 +==============================================================================
 +*130.159.196.118 193.62.22.90     2 u   78   64   36   61.470  -17.318  15.763
 + 78.129.190.21   85.199.214.102   2 u    9   64   37   13.979    0.712   0.680
 + 87.124.126.49   195.66.241.10    2 u    9   64   37   15.417    1.572   3.078
 + 192.146.137.13  82.148.230.254   2 u    8   64   37   42.823   -1.197   2.624
 +</file>
 +\\ 
 +After running the command <color #ed1c24>ntpq -pn</color> you should see a list of time servers (by IP) that the NTP service on the Raspberry Pi has connected to. The IP Address with the asterisk <color #ed1c24>*</color> next to it is the last server the Raspberry Pi did a time sync with.
 +\\ 
 +\\ 
  
 +----
 +==== Synchronising Clients ====
 +\\ 
 +** LINUX **
 +\\ 
 +\\ 
 +Synchronising <color #ed1c24>Linux</color> clients is pretty much the same as we have already done, except in the <color #ed1c24>/etc/ntp.conf</color> instead of putting internet time servers, you just enter the internal IP address of your NTP server.
 +\\ 
 +\\ 
 +** WINDOWS **
 +\\ 
 +\\ 
 +For <color #ed1c24>Windows</color> PCs we will have to set the NTP server in the time settings. To do this, first right click the clock in the bottom right hand side of the screen.
 +\\ 
 +\\ 
 +{{:ntp01.jpg?400|}}
 +\\ 
 +\\ 
 +Select 'Adjust date/time'
 +\\ 
 +\\ 
 +When the next page opens, scroll down.
 +\\ 
 +\\ 
 +{{:ntp02.jpg?700|}}
 +\\ 
 +\\ 
 +Select 'Additional date, time, & regional settings'
 +\\ 
 +\\ 
 +When the next page opens.
 +\\ 
 +\\ 
 +{{:ntp03.jpg?700|}}
 +\\ 
 +\\ 
 +Select 'Set the time and date'
 +\\ 
 +\\ 
 +On the next page.
 +\\ 
 +\\ 
 +{{:ntp04.jpg?400|}}
 +\\ 
 +\\ 
 +Select the 'Internet Time' tab.
 +\\ 
 +\\ 
 +On the next page.
 +\\ 
 +\\ 
 +{{:ntp05.jpg?400|}}
 +\\
 +\\
 +Select the Change Settings button.
 +\\ 
 +\\ 
 +On the next page we will see a box that contains <color #ed1c24>time.windows.com</color> 
 +\\ 
 +\\ 
 +{{:ntp07.jpg?400|}}
 +\\ 
 +\\ 
 +Change the contents of this box to the IP Address of the Raspberry Pi running the NTP server.
 +\\ 
 +\\ 
 +Finally, Click the <color #ed1c24>Update</color> Button.
 +\\ 
 +\\ 
 +{{:ntp08.jpg?400|}}
 +\\ 
 +\\ 
 +The time should now be updated, you will see confirmation in this page (I have to do this twice sometimes)
 +\\ 
 +\\ 
 +That's it.
 +\\ 
 +\\ 
  
 +----
 +==== Clients over 1000 Seconds out of time ====
 +\\ 
 +“NTP won’t normally reset the clock if it’s off by more than 1000s. If you run:
 +<file>
 +ntpd -gq’
 +</file>
 +It ignores the clock being way adrift from ntp time and will force it to be correct then close. The old ntpdate program does the same thing.”
 +\\ 
 +\\ 
 +Credit: [[http://www.raspberrypi.org/phpBB3/viewtopic.php?f=91&t=16058|External Link]] 
 +\\ 
 +\\ 
  
 +----
 +==== Raspberry Pi Dropping of Wireless Network ====
  
 +I found my raspberry Pi Zero, that is using the official Raspberry Pi Wireless Dongle drops off the wireless network after around a week. Only a reboot gets it back (as I have no keyb/mouse connected) so I figured just using Cron to reboot the thing every 24 hours will be a suitable work around.
 +\\ 
 +\\ 
 +To use cron (should already be installed):
 +\\ 
 +\\ 
 +    sudo crontab -e (reboots require super user rights)
 +\\ 
 +Insert the following line:
 +\\ 
 +\\ 
 +    0 0          /sbin/shutdown -r
 +\\ 
 +Explanation:
 +\\ 
 +\\ 
 +<file>
 +m      h    dom        mon   dow       command
 +minute hour dayOfMonth Month dayOfWeek commandToRun
  
 +so the line 
 +  0 0          /sbin/shutdown -r
  
- +would reboot your system every day at 00:00. 
- +</file
- +\\  
- +Use Ctrl+X, Y, EnterThis will save and exit crontab (if using nano) 
- +\\  
- +\\  
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
-<sxh [txt][; options for SyntaxHighlighter]+
-============================================================================== +
- 129.250.35.250  249.224.99.213   2 u   17   64    1   14.476   -0.987   0.001 +
- 109.74.206.120  129.69.1.153     2 u   16   64    1   11.470   -2.075   0.001 +
- 46.101.52.119   81.174.136.35    2 u   15   64    1   12.037   -0.254   0.001 +
- 162.213.34.249  145.238.203.14   2 u   14   64    1   11.887   -0.114   0.001 +
-pi@PiNTP:~ $ date +"%FT%T%Z" +
-2017-01-22T20:20:22UTC +
-pi@PiNTP:~ $ date +
-Sun 22 Jan 20:20:28 UTC 2017 +
-pi@PiNTP:~ $ ntpq -pn +
-     remote           refid      st t when poll reach   delay   offset  jitter +
-============================================================================== +
- 129.250.35.250  249.224.99.213   2 u   17   64    3   12.131   -0.813   0.173 +
- 109.74.206.120  129.69.1.153     2 u   19   64    3   17.051   -5.251   3.175 +
- 46.101.52.119   81.174.136.35    2 u   17   64    3   12.437   -0.767   0.513 +
- 162.213.34.249  145.238.203.14   2 u   17   64    3   12.664   -0.506   0.392 +
-pi@PiNTP:~ $ ntpq -pn +
-     remote           refid      st t when poll reach   delay   offset  jitter +
-============================================================================== +
-*129.250.35.250  249.224.99.213   2 u   21   64  177   10.248    0.334   0.864 +
--109.74.206.120  129.69.1.153     2 u   23   64  177   10.696   -1.835   8.592 +
-+46.101.52.119   81.174.136.35    2 u   18   64  167   11.125    0.393   0.716 +
-+162.213.34.249  193.79.237.14    2 u   15   64  177   11.887   -0.114   2.181 +
-</sxh>+
  
the_ntp_functions.txt · Last modified: 2023/03/09 22:35 by 127.0.0.1