[ "$verbose" -gt 0 ] && echo "$*"
logger -p daemon.info -t "$SELF" "$*"
}
+format_timedelta() {
+ local secs="$1"; shift
+ if [ "$secs" -ge 86400 ]; then
+ printf '%dd %02d:%02d:%02d\n' $(($secs/3600/24)) $(($secs/3600%24)) $(($secs/60%60)) $(($secs%60))
+ else
+ printf '%02d:%02d:%02d\n' $(($secs/3600)) $(($secs/60%60)) $(($secs%60))
+ fi
+}
if [ "${1:-}" = "-h" ] || [ "${1:-}" = "--help" ]; then
delta=$(( now - mtime ))
if [ "$delta" -lt "$MIN_WAIT" ]; then
runme=0
- log "Skipping $host:$port $version/$cluster because last attempt was only ${delta}s ago."
+ log "Skipping $host:$port $version/$cluster because last attempt was only $(format_timedelta "${delta}") ago."
else
if ! [ -e "$flagfilesuccess" ]; then
runme=1
delta=$(( now - mtime ))
if [ "$delta" -lt "$MIN_WAIT_SUCCESS" ]; then
runme=0
- log "Skipping $host:$port $version/$cluster because last success was only ${delta}s ago."
+ log "Skipping $host:$port $version/$cluster because last success was only $(format_timedelta "${delta}") ago."
elif [ "$delta" -gt "$MAX_WAIT_SUCCESS" ]; then
runme=1
- log "Planning to run $host:$port $version/$cluster because last success was ${delta}s ago."
+ log "Planning to run $host:$port $version/$cluster because last success was $(format_timedelta "${delta}") ago."
else
# get a "randomish" but stable value for this backup run
val=$(echo "$MYHOSTNAME-$host-$port-$mtime" | sha256sum | head -c 8)