Solved

bat script for Win XP, How can I sleep the process

Posted on 2009-03-30
3
491 Views
Last Modified: 2012-05-06
Hi,

See my bat file for XP

@ECHO OFF
:start
test.exe
sleep 300
goto start

I want to set delay of 5 min (300s), but it is throwing the error
"'sleep' is not recognized as an internal or external command"
In Linux I can use sleep, what is the equivalent in Win XP and Win 2003 server.
Basicaly I want to execute the test.exe in every 5 min.
0
Comment
Question by:spectrumsofttech
3 Comments
 
LVL 28

Expert Comment

by:TextReport
ID: 24016696
0
 
LVL 19

Expert Comment

by:PeteJThomas
ID: 24017070
Can you not just remove the sleep line and then schedule the bat file to run every 5 mins? Or is that not an option?
0
 
LVL 68

Accepted Solution

by:
Qlemo earned 500 total points
ID: 24019630
The traditional approach for a sleep is, as found in many posts here, to use a ping on localhost. It does not consume CPU, and needs no other resources:

@ECHO OFF
:start
test.exe
ping -n 301 127.0.0.1 >nul
goto start

You need to use 301 as ping starts a ping, waits a second, than pings again ... To build a fence with n segments, you need n+1 poles ;-).

A variant would be to use the timeout of ping with a non-existent target:

ping -n 1 -w 300 1.1

0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Using dates in 'DOS' batch files has always been tricky as it has no built in ways of extracting date information.  There are many tricks using string manipulation to pull out parts of the %date% variable or output of the date /t command but these r…
VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now