Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Possible Duplicate:
How to sleep in a batch file?

I have a batch file that runs as a secheduled task in windows server 2003.

This batch file purely calls around 20 other batchfiles one after the other.

When this runs it causes quite a spike on the server and a reduction in performance.

I'd like the ability to add a WAIT or SLEEP type command between each of my batch file calls in order to spread the load out a bit.

Can anyone shed any light on the simplest way of doing this?

share|improve this question

marked as duplicate by Massimo, MDMarra, Mark Henderson Sep 26 '12 at 20:25

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

up vote -5 down vote accepted

The code you are looking for, looks like this:

ping -n 11 > NUL

The value after "-n" indicates the seconds to wait.
If you want to wait 10secs just add one more ping,
like shown in the example.

Best regards.

P.S.: If you use the powershell, there may be other ways to do this.

share|improve this answer
In PowerShell there is Start-Sleep for that, right :-) – Joey Oct 2 '09 at 16:41
Using ping to pause batch execution is definitely more appropriate for than ServerFault... – Massimo Sep 26 '12 at 19:38

The correct way to sleep in a batch file is to use the timeout command, introduced in Windows 2000.

To wait 30 seconds:

timeout /t 30

The timeout would get interrupted if the user hits any key; however, the command also accepts the optional switch /nobreak, which effectively ignores anything the user may press, except an explicit CTRL-C:

timeout /t 30 /nobreak

Additionally, if you don't want the command to print its countdown on the screen, you can redirect its output to NUL:

timeout /t 30 /nobreak > NUL
share|improve this answer

There's a W2K3 resource kit utility called sleep.exe that you can use by calling it in the batch file and telling it how long to "sleep" before moving on to the next command.


net use X: \server\share /Delete

sleep 300

net use X: \server\share

share|improve this answer

The best way is to use 'ping', but you can find more ways here:

share|improve this answer
That's by no means "the best way". – Massimo Sep 26 '12 at 19:37

Not the answer you're looking for? Browse other questions tagged or ask your own question.