Ben's notes

Linux, Unix, network, radio...

User Tools

Site Tools


pc_engines_apu_ublox_6_timing_gps_ntp

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
pc_engines_apu_ublox_6_timing_gps_ntp [2015/01/06 09:37] – [Verify clients] adminpc_engines_apu_ublox_6_timing_gps_ntp [2015/01/24 17:39] – [Leap second file] admin
Line 83: Line 83:
  
 # By default, exchange time with everybody, but don't allow configuration. # By default, exchange time with everybody, but don't allow configuration.
-restrict -4 default kod notrap nomodify nopeer noquery +restrict -4 default limited kod notrap nomodify nopeer noquery 
-restrict -6 default kod notrap nomodify nopeer noquery+restrict -6 default limited kod notrap nomodify nopeer noquery
  
 # Local users may interrogate the ntp server more closely. # Local users may interrogate the ntp server more closely.
Line 92: Line 92:
   * Disable automatic update of ntp package. Remember to update it yourself in case of security updates!<code>sudo apt-mark hold ntp ntp-doc</code>   * Disable automatic update of ntp package. Remember to update it yourself in case of security updates!<code>sudo apt-mark hold ntp ntp-doc</code>
   * Reboot and check results.   * Reboot and check results.
 +
 +====Leap second file====
 +Automatic download of new leap second file.
 +
 +  * Install lftp. <code>apt-get install lftp</code>
 +  * Create leap second download script: [[get_leap_script|/usr/local/bin/get_leap.sh]]
 +  * Change executable mode <code>chmod +x /usr/local/bin/get_leap.sh</code>
 +  * Download new file weekly. Create **/etc/cron.weekly/leapsecond** <code>#!/bin/bash
 +
 +/usr/local/bin/get_leap.sh</code>
 +  * Change executable mode <code>chmod +x /etc/cron.weekly/leapsecond</code>
 ====Verify==== ====Verify====
   * Make sure gpsd and ntpd start at boot. If not, enable it.<code>update-rc.d ntp enable   * Make sure gpsd and ntpd start at boot. If not, enable it.<code>update-rc.d ntp enable
Line 125: Line 136:
 *SHM(0)          .GPSd.           0 l   16   16  377    0.000   -8.657   2.708 *SHM(0)          .GPSd.           0 l   16   16  377    0.000   -8.657   2.708
 </code> </code>
-====Leap second file==== 
-Automatic download of new leap second file. 
- 
-  * Install lftp. <code>apt-get install lftp</code> 
-  * Create leap second download script **/usr/local/bin/get_leap.sh** <code>#!/bin/bash 
- 
-# This script will download the latest leap second file, 
-# update the NTP configuration and restart ntpd. 
- 
-# Leap second file location 
-leapremote="ftp://time.nist.gov/pub/" 
-#leapremote="ftp://tycho.usno.navy.mil/pub/ntp/" 
- 
-# Local file name 
-leaplocaldir="/var/lib/ntp/" 
-leaplocalfile="$leaplocaldir/leap-seconds" 
- 
-# Log file 
-logfile=/var/log/getleap.log 
- 
-# Get latest leap second file 
-/usr/bin/lftp -e 'set net:timeout 10 ; cls -1 --sort=date | head -1 > /tmp/leap ; exit' $leapremote 
-if [ $? -ne 0 ]; then 
-  echo "`date` - FTP problem, exiting." | tee -a $logfile 
-  exit 1 
-fi 
- 
-if [ -f "$leaplocaldir$(cat /tmp/leap)" ]; then 
-  echo "`date` - File $leaplocaldir$(cat /tmp/leap) already exists. Not downloading." | tee -a $logfile 
-else 
-  cd "$leaplocaldir" 
-  /usr/bin/lftp -e "set net:timeout 10 ; get $(cat /tmp/leap) ; exit" $leapremote 
-  ln -sfn "$leaplocaldir$(cat /tmp/leap)" "$leaplocalfile" 
-  if [ $? -eq 0 ]; then 
-    echo "`date` - Leap second file downloaded." | tee -a $logfile 
-  else 
-    echo "`date` - Leap second file download problem." | tee -a $logfile 
-    exit 1 
-  fi 
-  service ntp restart 
-  if [ $? -eq 0 ]; then 
-    echo "`date` - NTPd service restarted succesfully." | tee -a $logfile 
-  else 
-    echo "`date` - NTPd service restart problem!" | tee -a $logfile 
-    exit 1 
-  fi 
-fi 
-</code> 
-  * Change executable mode <code>chmod +x /usr/local/bin/get_leap.sh</code> 
-  * Download new file weekly. Create **/etc/cron.weekly/leapsecond** <code>#!/bin/bash 
- 
-/usr/local/bin/get_leap.sh</code> 
-  * Change executable mode <code>chmod +x /etc/cron.weekly/leapsecond</code> 
- 
-====Verify==== 
   * Show connected clients:<code>ntpdc -c monlist</code>   * Show connected clients:<code>ntpdc -c monlist</code>
   * Verify leap variables:<code>ntpq -c "rv 0"   * Verify leap variables:<code>ntpq -c "rv 0"
pc_engines_apu_ublox_6_timing_gps_ntp.txt · Last modified: 2021/10/09 15:14 by 127.0.0.1