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...")
 
m (Ovidiu moved page Bash Timeout Loop to Bash Timeout Loops without leaving a redirect)
(No difference)

Revision as of 19:50, 5 May 2021

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