How to Sleep or Wait X Seconds in a Bat File

timeout (> Windows 7 / 2008)

timetout delays the execution for the given seconds.

Syntax

timeout <seconds> /nobreak

<seconds> is any value between -1 and 100000. -1 causes the computer to wait indefinitely until a keystroke.

/nobreak ignores user key strokes and the waiting could be disturbed by any keystroke.

timeout Example

timeout /t 5

It will pause 5 seconds before the next execution.

batch timeout example

ping command to introduce the delay

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 loop back address - 127.0.0.1 could also produce the 1 second delay between each consecutive ping, and it consumes less CPU load.

ping delay Example

ping -n 6 127.0.0.1>nul

6 means the delay is set to 6-1=5 seconds.

>nul pipes the standard-output stream to null and therefore there is no information displayed in the console.

ping dealy example