From 6a28ac2d92479ff555111cfa2bb04f721d9017f2 Mon Sep 17 00:00:00 2001 From: Benoit Vianin Date: Sat, 4 Nov 2023 18:53:42 +0000 Subject: [PATCH] Fix code for absolute time --- install/etc/services.available/10-db-backup/run | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/install/etc/services.available/10-db-backup/run b/install/etc/services.available/10-db-backup/run index de44578..368b5fc 100755 --- a/install/etc/services.available/10-db-backup/run +++ b/install/etc/services.available/10-db-backup/run @@ -25,8 +25,12 @@ else target_time=$(($current_time + $waittime)) elif [[ $DB_DUMP_BEGIN =~ ^[0-9]+$ ]]; then print_debug "DB_DUMP_BEGIN is an integer." - waittime=$(( ${BASH_REMATCH[1]} * 60 )) - target_time=$(($current_time + $waittime)) + + target_time=$(date --date="${today}${DB_DUMP_BEGIN}" +"%s") + if [[ "$target_time" < "$current_time" ]]; then + target_time=$(($target_time + 24*60*60)) + fi + waittime=$(($target_time - $current_time)) elif [[ $DB_DUMP_BEGIN =~ ^([0-9]{4})-([0-9]{2})-([0-9]{2})[[:space:]]([0-9]{2}):([0-9]{2}):([0-9]{2})$ ]]; then # Extract year, month, day, hours, minutes, and seconds from DB_DUMP_BEGIN