From a824953ded4506b6233ba898ccb75744ad4f8bf7 Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Thu, 12 Jan 2023 19:03:16 +0100 Subject: [PATCH] Update to allow next-day times Signed-off-by: Knut Ahlers --- bin/sleep-until | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/sleep-until b/bin/sleep-until index 48af6c5..8f03d0b 100755 --- a/bin/sleep-until +++ b/bin/sleep-until @@ -7,6 +7,7 @@ time=${1:-} [ -z "${time}" ] && fail "No time specified" tdiff=$(($(date -d "$1" +%s) - $(date +%s))) -step "Sleeping ${tdiff}s until ${time}..." +[ $tdiff -gt 0 ] || tdiff=$((tdiff + 86400)) +step "Sleeping ${tdiff}s until $(date -d "now + ${tdiff} seconds" "+%Y-%m-%d %H:%M:%S")..." sleep ${tdiff}