Bash Timeout Loops

From NovaOrdis Knowledge Base
Revision as of 04:16, 11 March 2020 by Ovidiu (talk | contribs) (Created page with "=Internal= * bash =Overview= <syntaxhighlight lang='bash'> ... local timeout_sec=... local t0=$(date '+%s') local remaining=$(expr ${timeout_sec...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Internal

Overview

...
local timeout_sec=...
local t0=$(date '+%s')
local remaining=$(expr ${timeout_sec} + ${t0} - $(date '+%s'))
while [[ ${remaining} -gt 0 ]]; do
    debug "remaining ${remaining} secs ..."
    sleep 1
    remaining=$(expr ${timeout_sec} + ${t0} - $(date '+%s'))
done