Hi everyone,
I thought I'd share an interesting script I wrote with some help from the Internet.
I am a fan of space weather and NOAA publishes a three-day space weather forecast that I wanted to post into the
Fidonet HAM echo and in Micronet's MIN_WEATHER echo. Unfortunately, cron does not work with a three-day
schedule. Here's what I finally came up with (the last procedure is how I post the message into MBSE):
===
#!/bin/bash
# The following is from:
#
https://askubuntu.com/questions/829408/execute-bash-script-literally-after-ever y-3-days
# This is to account for actually running every three days
# correctly since cron can't do it.
# Minimum delay between two script executions, in seconds. seconds=$((60*60*24*3))
# Compare the difference between this script's modification time stamp
# and the current date with the given minimum delay in seconds.
# Exit with error code 1 if the minimum delay is not exceeded yet.
if test "$(($(date "+%s")-$(date -r "$0" "+%s")))" -lt "$seconds" ; then
echo "This script may not yet be started again."
exit 1
fi
# Store the current date as modification time stamp of this script file
touch -m -- "$0"
# Insert your normal script here:
MBSE_ROOT=/opt/mbse;export MBSE_ROOT
cd $MBSE_ROOT/temp
lynx -dump "
https://services.swpc.noaa.gov/text/3-day-forecast.txt" > forecast # Micronet MIN_WEATHER
$MBSE_ROOT/bin/mbmsg post "Sean Dennis" All 65 "3 Day Space Weather Forecast" ./forecast - -quiet
# Fidonet HAM
$MBSE_ROOT/bin/mbmsg post "Sean Dennis" All 117 "3 Day Space Weather Forecast" ./forecast - -quiet
cp ./forecast $MBSE_ROOT/share/int/txtfiles/en/space_forecast.asc
### Kill off the text file
rm -f ./forecast
===
-- Sean
... Health is merely the slowest possible rate at which one can die.
--- MultiMail/Win
* Origin: Outpost BBS * Johnson City, TN (86:10/1)