There is no straight forward sleep command in Windows. All Unix variants provides this command to provide delay in shell scripts. I circumvent this I am using ping command as given below which provides sleep functionality with approximate accuracy. Ping command is used to check the connectivity between to machines in a network.
The below command will create 2 seconds delay. Let’s see how it works.
ping -w 1000 -n 2 1.1.1.1 > NULL
ping : Ping the specified host machine
-w timeout: Timeout in milliseconds to wait for each reply (I have selected 1000 to make unit as 1 second)
-n count: Number of echo requests to send (No.of seconds to sleep)
1.1.1.1: Dummy IP Address
> NULL: To eliminate the unwanted message
To adjust for better accuracy you can play with different values for -w argument. You can have this command in a batch file called sleep.bat and pass time in seconds as argument like this. Here is the sleep.bat
@echo off
ping -w 1000 -n %1 1.1.1.1 > NUL
Call this batchfile as “sleep 2″ for seconds and so.
Note: Windows Resource kit provides this functionality, but it involves agreeing to some license and massive download – where sleep is part of a big tool kit. It is available here.
More posts in this category
- How to access remote linux machine files through SSH from GNOME File browser Nautilus
- How to configure NFS Server and mount it in Ubuntu
- Automated Data backup of Ubuntu Linux using Remote Backup software rsnapshot in Debian
- How to setup Free GPS navigation for Nokia Smartphone without data connection
- Installing Debian GNU/Linux on QNAP TS-110 NAS Box









No Comments on “Sleep command in Windows (delay)”
You can track this conversation through its atom feed.