Ben's notes

Linux, Unix, network, radio...

User Tools

Site Tools


pc_engines_apu_ublox_6_timing_gps_ntp

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Last revisionBoth sides next revision
pc_engines_apu_ublox_6_timing_gps_ntp [2015/01/06 09:46] – [Install and configure NTPd] adminpc_engines_apu_ublox_6_timing_gps_ntp [2015/01/24 17:39] – [Leap second file] admin
Line 97: Line 97:
  
   * Install lftp. <code>apt-get install lftp</code>   * Install lftp. <code>apt-get install lftp</code>
-  * Create leap second download script **/usr/local/bin/get_leap.sh** <code>#!/bin/bash +  * Create leap second download script: [[get_leap_script|/usr/local/bin/get_leap.sh]]
- +
-# 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>   * 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   * Download new file weekly. Create **/etc/cron.weekly/leapsecond** <code>#!/bin/bash
Line 146: Line 103:
 /usr/local/bin/get_leap.sh</code> /usr/local/bin/get_leap.sh</code>
   * Change executable mode <code>chmod +x /etc/cron.weekly/leapsecond</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
pc_engines_apu_ublox_6_timing_gps_ntp.txt · Last modified: 2021/10/09 15:14 by 127.0.0.1