Bash Timeout Loops: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
(Created page with "=Internal= * bash =Overview= <syntaxhighlight lang='bash'> ... local timeout_sec=... local t0=$(date '+%s') local remaining=$(expr ${timeout_sec...")
(No difference)

Revision as of 04:16, 11 March 2020

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