简体   繁体   English

批处理文件,每1分钟执行一次命令

[英]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. 我想创建一个每1分钟在其中执行命令的批处理文件。

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. 每1分钟将文件从somedomain.com/updates.html下载到一个新文件。 or so i don't have any .NET framework installed here, so i thought of going with batch files. 或者,所以我这里没有安装任何.NET框架,所以我想到了批处理文件。

After googling a bit a got http://www.chami.com/tips/windows/062598W.html 谷歌搜索了一下之后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. 现在,我要调用的命令是每1分钟下载并写入一个新文件。

I recommend using Scheduled tasks in windows for this! 我建议为此在Windows中使用计划任务! Don't add the scheduling/loop in your batch file! 不要在您的批处理文件中添加计划/循环!

From http://malektips.com/dos0017.html 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. 在某些语言中,该命令将为WAIT,但是对于批处理文件,DOS和Windows都不随附此命令。 If you want to implement the WAIT command: 如果要实现WAIT命令:

For DOS, Windows 95, and Windows 98 machines 对于DOS,Windows 95和Windows 98计算机

Create the following batch file and name it WAIT.BAT. 创建以下批处理文件,并将其命名为WAIT.BAT。

@CHOICE /T:N,%1% > NUL @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: 现在,为了在批处理文件中等待10秒,只需按如下所示调用WAIT.BAT批处理文件:

CALL WAIT 10 呼叫等待10

For Windows 95, Windows 98, Windows NT, Windows 2000, Windows XP, or Windows 2003 machines 对于Windows 95,Windows 98,Windows NT,Windows 2000,Windows XP或Windows 2003计算机

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: 您可以使用以下WAIT.BAT,因为CHOICE命令不包括在Windows NT,Windows 2000,Windows XP或Windows 2003的默认安装中:

@ping 127.0.0.1 -n 2 -w 1000 > nul @ping 127.0.0.1 -n %1% -w 1000> nul @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. 这两行的原因是,为了等待使用PING命令,您必须添加额外的ping命令才能正确等待所需的秒数。 Also, since the PING command is being used, it is possible that this WAIT batch file may run over a few milliseconds. 另外,由于使用了PING命令,因此该WAIT批处理文件可能会运行几毫秒。 Thus, it is not recommended to use this for critical real-time processing. 因此,不建议将其用于关键的实时处理。

Windows XP and Windows 2003 machines Windows XP和Windows 2003计算机

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. 由于Windows XP和2003用户没有CHOICE命令,因此,如果您不喜欢PING替代方法,则Windows 2003资源工具包将提供一个批处理文件SLEEP命令。

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. 尽管命令提示符处没有等待命令,但这是一个常见问题,MS确实已将睡眠命令作为资源工具包的一部分发布。 You can just use the sleep.exe command in a while loop. 您可以在while循环中使用sleep.exe命令。

I got sleep.exe from the Windows 2003 Resource Kit which can be found online . 我从Windows 2003资源工具包中获得了sleep.exe,可以在网上找到它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM