Backend/compose/production/postgres/maintenance/_sourced/countdown.sh

13 lines
322 B
Bash
Raw Normal View History

2023-02-18 17:44:52 +03:00
#!/usr/bin/env bash
countdown() {
declare desc="A simple countdown. Source: https://superuser.com/a/611582"
local seconds="${1}"
local d=$(($(date +%s) + "${seconds}"))
while [ "$d" -ge `date +%s` ]; do
echo -ne "$(date -u --date @$(($d - `date +%s`)) +%H:%M:%S)\r";
sleep 0.1
done
}