Ok - don't laugh
My coding skills are pitiful so I asked my resident Ai to write a bash
script to call a webcam script (I did write this one) only between
sunrise and sunset. it produced this and it works! My question is - how
can I amend the script so it starts 30 minutes BEFORE sunrise and stops
30 Minutes after?
#!/bin/bash
# Set your latitude and longitude
LATITUDE="mine"
LONGITUDE="mine"
# Fetch sunrise and sunset times in UTC
SUN_TIMES=$(curl -s "
https://api.sunrise-sunset.org/json?lat=$LATITUDE&lng=$LONGITUDE&formatted=0") SUNRISE=$(echo $SUN_TIMES | jq -r '.results.sunrise')
SUNSET=$(echo $SUN_TIMES | jq -r '.results.sunset')
# Convert sunrise and sunset times to seconds since epoch
SUNRISE_EPOCH=$(date -d "$SUNRISE" +%s)
SUNSET_EPOCH=$(date -d "$SUNSET" +%s)
CURRENT_EPOCH=$(date +%s)
# Check if the current time is between sunrise and sunset
if [ $CURRENT_EPOCH -ge $SUNRISE_EPOCH ] && [ $CURRENT_EPOCH -le
$SUNSET_EPOCH ]; then
echo "It's between sunrise and sunset. Running the other script..."
# Call the other script
./webcam.sh # Replace with the path to your script
else
echo "It's not between sunrise and sunset."
fi
--- SoupGate-Win32 v1.05
* Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)