batch file to execute a command in it every 1 minute
i want开发者_运维技巧 to create a batch file that executes command in it every 1 minute.
how can i go ahead with this ?
what i want to do is :
download a file from somedomain.com/updates.html to a new file every 1 min. or so i don't have any .NET framework installed here, so i thought of going with batch files.
After googling a bit a got http://www.chami.com/tips/windows/062598W.html
now what i want is to call 1 command whic downloads & writes a new file every 1 minute.
From http://malektips.com/dos0017.html
Do you need a batch file that waits a certain amount of seconds? In some languages, the command would be WAIT, but DOS and Windows do not come with this command for batch files. If you want to implement the WAIT command:
For DOS, Windows 95, and Windows 98 machines
Create the following batch file and name it WAIT.BAT.
@CHOICE /T:N,%1% > NUL
Now, in order to wait 10 seconds in a batch file, just call the WAIT.BAT batch file as follows:
CALL WAIT 10
For Windows 95, Windows 98, Windows NT, Windows 2000, Windows XP, or Windows 2003 machines
You can use the following WAIT.BAT, as the CHOICE command is not included in the default install on Windows NT, Windows 2000, Windows XP, or Windows 2003:
@ping 127.0.0.1 -n 2 -w 1000 > nul @ping 127.0.0.1 -n %1% -w 1000> nul
The reason for the two lines is that in order to wait using the PING command, you must add extra pings to correctly wait the desired number of seconds. Also, since the PING command is being used, it is possible that this WAIT batch file may run over a few milliseconds. Thus, it is not recommended to use this for critical real-time processing.
Windows XP and Windows 2003 machines
Since Windows XP and 2003 users do not have the CHOICE command, if you find the PING alternative not to your liking, the Windows 2003 Resource Kit has a batch file SLEEP command.
I recommend using Scheduled tasks in windows for this! Don't add the scheduling/loop in your batch file!
While there is no wait command available at a command prompt, this was a common problem and MS did release a sleep command as part of the resource kit. You can just use the sleep.exe command in a while loop.
I got sleep.exe from the Windows 2003 Resource Kit which can be found online.
精彩评论