File: retry.bat

package info (click to toggle)
python-dateutil 2.9.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,316 kB
  • sloc: python: 12,720; makefile: 151; sh: 60
file content (18 lines) | stat: -rw-r--r-- 472 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
@echo off
REM This script takes a command and retries it a few times if it fails, with a
REM timeout between each retry.

setlocal EnableDelayedExpansion

REM Loop at most n_retries times, waiting sleep_time times between
set sleep_time=60
set n_retries=5

for /l %%x in (1, 1, %n_retries%) do (
  call %*
  if not ERRORLEVEL 1 EXIT /B 0
  timeout /t %sleep_time% /nobreak > nul
)

REM If it failed all n_retries times, we can give up at last.
EXIT /B 1