Adult life training inc banner
Menu
  • Home
  • Minutes
    • Minutes — Advisory Board
    • Minutes — Board of Directors
  • Ramsey+ Financial Peace
    • Introduction
    • Get your free Ramsey Plus Membership
    • Details for Managers
    • Sign Up for FPU Class
    • Get Coaching
    • Volunteer to Help
    • Underwriters
  • Computer Classes
    • Instructor Lead Classes
    • Individual Instruction
    • WIN System
    • Download Class Manuals
    • Creative Commons License
  • 501(c)(3) Info
    • Introduction
    • Determination Letter
    • Articles of Incorporation
    • Bylaws
  • Privacy Policy
  • About Us
    • Introduction
    • Contact Us
    • What we do
    • Mission Statement
    • Impact Statement
    • In Review – Year 2022
    • Board of Directors
      • John D. Nash, Jr.
      • Philip Lock
      • Jolene A. Nash
      • Paula Echols
      • John D. Nash, 3rd
    • Advisory Board
      • John D. Nash, Jr.
    • Non-Discrimination Policy
    • Conflict of Interest Policy
    • Effectiveness Assessment Policy
    • Funding Opportunities
    • Budget
    • Year to Date Financials
    • Last Year’s Financials
Menu

Server Side Weather data collection script for GNU/Linux

Posted on September 15, 2019September 15, 2020 by John Nash
see https://w1.weather.gov/xml/current_obs/ and https://alerts.weather.gov/

The following script is intended to run on your file server that collects data to distribute to your network. Safety is built in to prevent contacting NOAA weather.gov more than one time per hour. The data comes in .xml format and contains the recommended time to collect the data, per each region. Information on what files to request can be found by much digging and a visit to XML Feeds of Current Weather Conditions https://w1.weather.gov/xml/current_obs/ and NWS Public Alerts in XML/CAP and ATOM Formats https://alerts.weather.gov/ combined with close attention to the browser URL when you look at your weather on weather.gov.

#!/bin/bash
# pull weather from weather.gov
# But ONLY IF it has not been pulled recently
# weather is updated once per hour & recommended time to pull is hour+15
# program cron accordingly
# last_update: 20170826 JDN
#
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

# define minimum time lapse before new pull is permitted
declare -i MINAGE=22
echo 'Min age' $MINAGE

# calculate time lapsed since last pull
if [ -f wwraw.xml ];
then
  declare -i LAPSE=$(( ( $(date +%s) - $(stat wwraw.xml -c %Y)) / 60 ))
echo 'Lapse' $LAPSE
else
  declare -i LAPSE=999
fi

# allow override of command line parameter #1 is --force
if [ -n "$1" ]; then declare -i FORCE=1; else declare -i FORCE=0; fi
echo force is $FORCE

#log outside IP
echo "OpenDNS/Google" $(dig +short myip.opendns.com @resolver1.opendns.com) / $(dig TXT +short o-o.myaddr.l.google.com @ns1.google.com) >wwraw.xme

# calculate if pull is permitted (boolean)
DOPULL=$(( $LAPSE >= $MINAGE ))
echo dopull is $DOPULL

# test time lapse vs. minimum time lapse to allow pull or override
# Check if file older
if [[ $(($DOPULL + $FORCE)) -gt 0 ]]; then
# debugging message output if pull was performed
  echo "File was pulled $LAPSE minutes ago. Pulling new weather data"

# get surface observations
# file will have date / time from weather.gov
  wget -q --output-document="wwraw.xml" http://w1.weather.gov/xml/current_obs/KFWA.xml

# mark file with current time to prevent hammering weather.gov
  touch wwraw.xml

# get weather alerts
  wget -q --output-document="walerts.xml" http://alerts.weather.gov/cap/wwaatmget.php?x=INC003&y=0

else
# debugging message output if pull was not performed
  echo "File was pulled $LAPSE minutes ago. Ignoring request to pull again."
fi

#cleanup
unset FORCE
unset DOPULL
unset MINAGE
unset LAPSE
exit 0
Share on Social Media
x facebook pinterest linkedin tumblr reddit emailwhatsapptelegrammastodon
Category: General Information

Post navigation

← Sample .conkyrc file
Free: How to get more out of your money →
Donations to Adult Life Training, Inc. are deductible under IRC Section 170.
Click for details


Dave Ramsey FPU


Office 365


WIN System


Indiana Career Connect


Indiana Uplink CS3 System

Ramsey+ is FREE for your family through a 3Rivers Foundation grant.

Racially nondiscriminatory policy

“The Adult Life Training, Inc. school admits students of any race, color, and national origin and ethnic origin to all the rights, privileges, programs, and activities generally accorded or made available to students at the school. It does not discriminate on the basis of race, color, national origin, and ethnic origin in administration of its educational policies, admission policies, scholarship and loan programs, and athletic or other school-administered programs.” (Rev. Proc. 75-50, 1975-2 C.B. 587 Section .01 Rev. Rul. 71-447)

Subscribers

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org
©2025 Adult Life Training, Inc.
 

Loading Comments...
 

You must be logged in to post a comment.