8

I have several Rpi3s running Raspbian. They collect data and I use FileZilla to copy data from one to another. Ideally, I am only copying files that have changes or are new.

FileZilla can be installed on a PC at

FileZilla download (filezilla-project.org)

FileZilla can be installed in Raspbian with this command:

sudo apt-get update -y
sudo apt-get install FileZilla 

I have the options in FileZilla set to only overwrite existing files if they are newer. I also use chmod -w on my Archive directories on the target machines so only new files can be copied.

Yet FileZilla is spending way too much time copying files that are already there because the clocks on the Raspbians vary too much.

I want to set them all to a primary standard so they can agree better, thus minimizing the transfers of identical files.

According to the NIST page, the National Bureau of Standards suggests using time.nist.gov as the address that will reach a working system among all of the level 1 NTP servers available:

NIST Internet Time Servers

My question is in the title: How do I set Raspbian to use the primary time server time.nist.gov?

SDsolar
  • 2,208
  • 8
  • 24
  • 42
  • The clocks should not differ that much... How often are you trying to retrieve data? – Jacobm001 Jun 22 '17 at 17:07
  • 1
    The Stratum-16 pools installed by default would cause them to differ by more than the threshold of one second which triggers both FileZilla and ROBOCOPY to think it is a newer file. This links directly to a Stratum-1 source. No extra hops in between.. Both Linux and Windows use pools but there is no need to use them. time.nist.gov is smart enough to find the quickest server at the National Bureau of Standards or the Navy. The end result of doing this is truly amazing. 10:1 ratio of time savings or so. Plus, this is using SD cards so it saves on wear and tear. Highly recommended. – SDsolar Jun 24 '17 at 09:39
  • Before trying this, use ntpq -p to notice the St value. That shows how many hops you are away from the master clock. Generally it will be about 20. Our target is St=1 – SDsolar Aug 01 '17 at 05:56

2 Answers2

7

Time server settings are saved in /etc/ntp.conf so open your favorite editor and make this change.

sudo nano /etc/ntp.conf

The relevant section looks like this:

enter image description here

So all you need to do is change it to look like this on all the relevant computers:

enter image description here

then reboot them.

Voila, the systems are now all using the NIST/NBS Master Clock to synchronize.

You can verify that it is working at Level 1 by using this command:

ntpq -p

Which gave me this output:

enter image description here

FileZilla is now running unbelievably faster as it is able to skip more files!

Amazing difference. Time synchronization is an excellent experience.

This is the best that can be attained via the Internet

time.nist.gov is a load-balancer that points to the best server for any particular location.


GPS gives better accuracy, but not as easy to set up.

Here is a Q&A about setting up a U-Blox 7 type G-Mouse USB GPS on the Pi:

How can I set up my G-Mouse USB GPS for use with Raspbian?

This article describes setting up the software for the GPS and to get it working. We'll still need someone to explain how to use it to create a local authoritative NTP server that all the other Linux machines can use as their reference in order to attain the best possible level of time synchronization with the Raspberry Pi 3B and Raspbian.

Notice how Google does it. The have GPS and atomic clocks at each data center all around the world:

GOOGLE SPANS ENTIRE PLANET WITH GPS-POWERED DATABASE (from Wired)


In Windows this same change is even easier. Just click on the clock and follow the prompts to change the Internet time to time.nist.gov then update.

By doing that, even transfers into and out of Windows (for hard drive backups) are a LOT faster as it skips files with the same creation date on both sides.

This has a pleasant side-effect of minimizing the amount of time it takes to ROBOCOPY out to a backup drive, too.

SDsolar
  • 2,208
  • 8
  • 24
  • 42
  • This same approach works with Ubuntu 14.04 LTS. Except they have yet another line for a fall-back server, just below this block. I commented it out because time.nist.gov does not need any backup server definitions at the client side. It is a smart URL that finds the fastest-responding Stratum-1 system. The Master Clock. – SDsolar Jul 06 '17 at 07:38
  • Ubuntu 16.04 LTS requires the installation of ntp, first. Here are the basic instructions: help.ubuntu.com/lts/serverguide/NTP.html - once it is installed, the rest is similar - the only real difference is that the lines begin with pool and the one line you are activating needs to be started with server as shown above. However, 16.04 has much tighter file permissions so the work must be done in su mode. If you have forgotten your root password you can reset it from your normal prompt by using sudo passwd root. Then the su command will work. – SDsolar Jul 06 '17 at 08:30
  • Note that the St column shows the Stratum and that the value is 1 or 2, and it will prioritize St 1. `With the pools it is more like 20.` But in this case you can see it is Stratum-1 for highest possible accuracy. – SDsolar Aug 01 '17 at 05:52
  • Incidentally, instead of ntpq -p you can use ntpq -c peers – SDsolar Aug 01 '17 at 05:54
2

I have been fighting a problem with personally selected NTP sites since Raspbian Jessie. It seems that someone decided to force the setting of Debian pool servers into /etc/ntp.conf during each boot. Yesterday on this site, I found that the /etc/init.d/ntp script is the culprit. A simple edit of the file eliminates the pushing of the pool servers into ntp.conf. The script statements don't replace the whole file, but replace all servers you might have inserted, or replaced, so any other changes outside of the server definition area like GPS, PPS, etc. are untouched.

Simply edit /etc/ntp.conf, then find and comment out the lines shown below:

    # if [ -e /var/lib/ntp/ntp.conf.dhcp ]; then
    #     NTPD_OPTS="$NTPD_OPTS -c /var/lib/ntp/ntp.conf.dhcp"
    # fi

This will eliminate the changes at boot, and ntpd will use the /etc/ntp.conf as is.

Tom
  • 41
  • 4