fixes intervals

This commit is contained in:
olli 2024-02-06 13:42:22 +01:00
parent 1e3c389e90
commit a83247b4ca

View File

@ -49,18 +49,18 @@ do
rm -f firstloop
else
LOOP_INTERVAL=30 # 60s max free coingecko API interval + 30s puffer
time_to_interval=$((${LOOP_INTERVAL} - $(date +%s) % ${LOOP_INTERVAL}))
g_echo_note "NEXT LOOP - sleeping ${time_to_interval} seconds until next full ${LOOP_INTERVAL} seconds"
sleep ${time_to_interval}
# Check for next general interval
time_to_full_interval=$((${INTERVAL} - $(date +%s) % ${INTERVAL}))
time_to_interval=$((${LOOP_INTERVAL} - $(date +%s) % ${LOOP_INTERVAL}))
# Check for next general interval
g_echo_note "NEXT LOOP in ${time_to_interval} seconds (Interval=${LOOP_INTERVAL}s)"
g_echo_note "NEXT FULL LOOP in ${time_to_full_interval} seconds (Interval=${INTERVAL}s)"
if [ ${time_to_full_interval} -le ${time_to_interval} ]
then
g_echo_note "NEXT FULL LOOP NOW - all ${INTERVAL} seconds"
FULL_LOOP=1
sleep ${time_to_full_interval}
else
g_echo_note "NEXT FULL LOOP - ${INTERVAL} seconds in ${time_to_full_interval} seconds"
FULL_LOOP=0
sleep ${time_to_interval}
fi
fi