mirror of
https://github.com/openwrt/packages.git
synced 2025-12-16 07:31:20 +00:00
ddns-scripts: stash the next check time
Calculating the next check time based on the last update time is not very accurate if the next check is a large multiple forwards from the last update time because the cumulative sleeps and wake times are not exact but best effort of the OS. Other factors including clock-drift give rise to a larger time discrepancy the further the next update is in the future. Stash the next check time which should be quite accurate since it's only one sleep instance away. This is also for use in the GUI. Tested on 24.10.2 Signed-off-by: Paul Donald <newtwen+github@gmail.com>
This commit is contained in:
committed by
Florian Eckert
parent
296c15c1f2
commit
1463d79bdf
@@ -102,6 +102,7 @@ esac
|
||||
# set file names
|
||||
PIDFILE="$ddns_rundir/$SECTION_ID.pid" # Process ID file
|
||||
UPDFILE="$ddns_rundir/$SECTION_ID.update" # last update successful send (system uptime)
|
||||
CHKFILE="$ddns_rundir/$SECTION_ID.nextcheck" # next check (system uptime + check interval)
|
||||
DATFILE="$ddns_rundir/$SECTION_ID.dat" # save stdout data of WGet and other extern programs called
|
||||
ERRFILE="$ddns_rundir/$SECTION_ID.err" # save stderr output of WGet and other extern programs called
|
||||
IPFILE="$ddns_rundir/$SECTION_ID.ip" #
|
||||
@@ -397,7 +398,10 @@ while : ; do
|
||||
|
||||
# now we wait for check interval before testing if update was recognized
|
||||
[ $DRY_RUN -eq 0 ] && {
|
||||
write_log 7 "Waiting $CHECK_SECONDS seconds (Check Interval)"
|
||||
get_uptime NOW_TIME
|
||||
echo $(($NOW_TIME + $CHECK_SECONDS)) > $CHKFILE # save the next scheduled check time
|
||||
NEXT_CHECK_TIME=$( date -d @$(( $(date +%s) + $CHECK_SECONDS )) +"$ddns_dateformat" )
|
||||
write_log 7 "Waiting $CHECK_SECONDS seconds (Check Interval); Next check at $NEXT_CHECK_TIME"
|
||||
sleep $CHECK_SECONDS &
|
||||
PID_SLEEP=$!
|
||||
wait $PID_SLEEP # enable trap-handler
|
||||
|
||||
Reference in New Issue
Block a user