This Bash script serves as a cron helper for executing a command only during the period between sunrise and sunset at a specified location.
- Ensure you have Bash and the
jq
tool installed on your system. - Set your latitude, longitude, and timezone details in the script.
- Run the script using
bash sunny.sh && your_program
to executeyour_program
only during the period between sunrise and sunset.
- Latitude and Longitude: Specify your geographical coordinates (latitude and longitude) in the script where you want to check the sunrise and sunset times.
- Timezone: Adjust the timezone difference from UTC in the
TZD
variable. For example, if your timezone is UTC+5:30, setTZD="5 hours 30 minutes"
. - Extension Period: The period can be extended on either or both sides by adjusting the
TBSR
(time before sunrise) andTBSS
(time after sunset) variables in seconds.
bash sunrise_sunset_cron.sh && your_program