cfg/bin/sleep-until
Knut Ahlers a824953ded
Update to allow next-day times
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2023-01-12 19:04:11 +01:00

13 lines
327 B
Bash
Executable file

#!/bin/bash
set -euo pipefail
source ${HOME}/bin/script_framework.sh
time=${1:-}
[ -z "${time}" ] && fail "No time specified"
tdiff=$(($(date -d "$1" +%s) - $(date +%s)))
[ $tdiff -gt 0 ] || tdiff=$((tdiff + 86400))
step "Sleeping ${tdiff}s until $(date -d "now + ${tdiff} seconds" "+%Y-%m-%d %H:%M:%S")..."
sleep ${tdiff}