如何在 Windows 命令提示符下每 5 分钟安排一次任务?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28855087/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 18:59:07  来源:igfitidea点击:

how to schedule a task for every 5 minutes in windows command prompt?

windowsscheduled-taskscommand-promptwindows-task-scheduler

提问by Yosuva A

I'm currently scheduling .batfiles using Windows Task Scheduler. However, I want to do this using the Command Prompt's schtaskscommand. My batch file should run every five minutes and repeat its task every day.

我目前正在.bat使用 Windows 任务计划程序计划文件。但是,我想使用命令提示符的schtasks命令来执行此操作。我的批处理文件应该每五分钟运行一次并每天重复执行它的任务。

回答by Cristian Marian

I don't have much experience with .bat file (and maybe what I am about to write is nonsence), but I was wondering if a GOTO and a delay can resolve your problem.

我对 .bat 文件没有太多经验(也许我要写的是废话),但我想知道 GOTO 和延迟是否可以解决您的问题。

:label
<do stuff>
SLEEP 300
GOTO label

LE: Ok, I found something that might help you:

LE:好的,我找到了一些可能对你有帮助的东西:

schtasks /create /sc minute /mo 5 /tn "TaskName" /tr \scripts\whatever.bat

This line should do the trick. For more information you can visit https://technet.microsoft.com/en-us/library/cc772785(v=ws.10).aspx

这条线应该可以解决问题。有关更多信息,您可以访问https://technet.microsoft.com/en-us/library/cc772785(v=ws.10).aspx