This article will introduce how to sleep or wait
x seconds in a bat file. Bat file execution pauses
x seconds and then continues with the next commands.
Batch Sleep With
timeout (> Windows 7 / 2008)
timetout delays the execution for the given seconds.
timeout <seconds> /nobreak
<seconds> is any value between -1 and 100000.
-1 causes the computer to wait indefinitely until a keystroke.
/nobreak ignores user keystrokes and the waiting could not be disturbed by any keystroke.
timeout Bat Sleep Example
timeout /t 5
It will pause 5 seconds before the next execution.
Batch Wait With
Although PC pauses the command execution for
x seconds when you use
timeout command, it still consumes quite a lot of the CPU load.
ping command with a loopback address -
127.0.0.1 could also produce the 1-second delay between each consecutive ping, and it consumes less CPU load.
ping Bat Wait Example
ping -n 6 127.0.0.1>nul
6 means the delay is set to
>nul pipes the standard-output stream to
null and therefore there is no information displayed in the console.