• Odd-day script

    From Sean Dennis@1:18/200 to Nigel Reed on Sun Apr 9 21:00:14 2023
    Nigel Reed wrote to All <=-

    Easily mitigated. Just run a cronjob each month to call a script
    that'll check an incremental file. When it reaches 10 complete the
    script and reset to 1 otherwise increment.

    I cribbed this script together with help to run every three days when
    NOAA updates their space weather forecast. The daily cron job runs this at 0900 ET:

    ===
    #!/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 $MBSE_ROOT/bin/mbmsg post All 155 "3-Day Space Weather Forecast" ./forecast - -quiet
    ### Kill off the text file
    rm -f ./forecast
    ===

    I haven't tried using this script under sh yet.

    This might be helpful.

    -- Sean

    ... Inside every large problem is a small problem trying to get out.
    --- MMail/FreeBSD
    * Origin: Outpost BBS * Johnson City, TN (1:18/200)