Sleep/Pause on the command line

A quick simple way to make the command line stop executing for a certain amount of time is by put

Everyone once in a while I need a way to stop the command line from executing for a certain number of seconds. By putting the 2 below lines in to a sleep.bat file I am able to create this functionality.

@ping 127.0.0.1 -n 2 -w 1000 > nul
@ping 127.0.0.1 -n %1% -w 1000> nul

In order to use this I just type "sleep 10" which will mimic a pause for 10 seconds (really it runs a ping in the background for 10 seconds).

Related Posts:

One Response to “Sleep/Pause on the command line”

  1. luky Says:

    The -w parameter specifies maximum time to wait for each reply. And you are pinging your loopback (127.0.0.1) which responds always and immediately. It is wrong. It is just a luck that one ping takes around 1 second on your PC. You can ping an address that doesn't respond to pings to take advantage of delay timing with -w.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Notify me of followup comments via e-mail. You can also subscribe without commenting.