Windows 任务计划程序可在几秒钟内执行任务
我正在寻找一个适用于 Windows 7(开发机器)的开源/免费任务调度程序,它允许我安排任务(对 Web 服务的 HTTP 请求)每 x 秒运行一次。
我尝试过几个 Cron 克隆和 Windows 自己的任务计划程序,但似乎都不允许任务以小于 60 秒的间隔运行。我错过了什么吗?如果可能的话,我也不想去编写任何自定义脚本。
I'm looking for an open source/free task scheduler for Windows 7 (development machine) that will allow me to schedule tasks (HTTP requests to a web service) to run every x seconds.
I've tried a couple of Cron clones and windows own Task Scheduler but neither seem to allow tasks to run at intervals less than 60 seconds. Am I missing something? I don't want to have to go and write any custom scripts either if possible.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
可以为一项计划任务创建多个触发器。如果您创建 59 个相同的触发器,彼此之间有 1 秒的偏移,并计划任务本身每分钟运行一次,则最终计划任务每秒运行一次。
您可以使用 GUI 手动创建这 59 个触发器。然而,创建如此多触发器的一种更快的方法是创建一个包含一个或两个触发器的任务,将其导出到文本文件,复制相应的行,相应地更改起始偏移量,然后重新导入文件。
It is possible to create multiple triggers for one scheduled task. If you create 59 identical triggers with an offset of 1 second to each other, and schedule the task itself to run every minute, you end up the scheduled task to run every second.
You could create those 59 triggers manually using the GUI. However, a much quicker way to create so many triggers is to create a task with one or two triggers, export it to a text file, duplicate the according lines, change the start offsets accordingly, and then re-import the file.
我实际上能够实现这一目标。
更新:似乎我把它复杂化了。
在触发器中,它显示“重复任务间隔:”实际上,您可以在下拉列表中键入“1 分钟”(它不会让您以秒为单位键入时间)
我在 Windows 7 计算机上执行了此操作。
另外,我显然没有很好地阅读问题,因为提问者似乎已经能够将时间缩短到 1 分钟。不过,我将把这个答案留在这里,因为它将向未来的读者解释如何将时间缩短到一分钟。
看起来你确实无法让它以少于一分钟的间隔运行。
我设置了一个任务,触发器设置为“每日”,每 1 天重复一次。
我选中“重复任务间隔:”框。将其设置为 5 分钟,持续时间为 1 天
这会使任务永远进行一次,每 5 分钟一次。
然后我导出了任务。它导出到 .xml 文件。
在
任务>下触发器>日历触发>重复
有以下标签:PT5M
我将其从PT5M
更改为PT1M
。我重新导入了任务。该任务现在每 1 分钟运行一次。
我还没有完全测试过这一点,并且我也没有尝试过不到一分钟,但通过放置 PT30S 或其他东西 30 秒也许是可能的。我会尝试一下并报告回来。 更新:您不能执行此操作,导入任务时会出现错误。无法将此时间设置为少于 1 分钟。
整个触发器对我来说如下所示:
I was actually able to achieve this.
Update: Seems I over complicated it.
In the trigger, where it says "Repeat task every:" you can actually TYPE into the drop-down "1 minute" (It wont let you type the time in seconds)
I did this on a Windows 7 machine.
Also, I clearly did not read the question well enough, as the asker seems to already have been able to get the time down to 1 minute. However, I'll leave this answer here, as it will explain for future readers exactly how to get the time down to one minute.
It does seem as though you cannot get it to run at an interval of less than one minute.
I set up a task with a trigger set to Daily to recur every 1 day.
I check the "Repeat task every:" box. Setting it to 5 Minutes for a duration of 1 day
This makes the task go forever, every 5 minutes.
I then exported the task. It exports to a .xml file.
Under
Task > Triggers > CalendarTrigger > Repeition
there is the following tag:<Interval>PT5M</Interval>
I changed it fromPT5M
toPT1M
. I re-imported the task.The task now runs every 1 minute.
I have not fully tested this, and I have not tried with less than one minute, but it might be possible by putting
PT30S
or something for 30 seconds. I'll try it out and report back. Update: You cannot do this, you get an error when importing the task. It's not possible to set this time to less than 1 minute.The whole trigger looks like this for me:
我已经用谷歌搜索了这个问题,据我所知,答案是没有。有很多商业解决方案,但没有开源/免费程序。
我最终使用 quartz 调度程序 在 java 中编写了一个非常简单的定期 HTTP GET 调度程序。这可能对其他人有用,因此在 guthub https://github.com/bjordan/simple_java_periodic_HTTP_scheduler< /a>
I've googled this to death, so as far as I can see the answer is, there are none. There are plenty of commercial solutions, but no open source/free programs.
I ended up writing a very simple periodic HTTP GET scheduler in java using quartz scheduler. It may be useful to other so posting a link to the source on guthub https://github.com/bjordan/simple_java_periodic_HTTP_scheduler
简短说明:
主程序启动一个服务进程,该进程将在内存中保持活动状态,并定期激活一项作业——做某事。
这是我的模板 C# 解决方案.NET/Mono 中的 Windows 服务和 Linux 恶魔 https://github.com/mchudinov/ServiceDemon
以及一篇关于它的简短博文
<代码>
<代码>
Short explanation:
Main program starts a service process that will stay active in memory and will periodically activate a job – do something.
Here is my template C# solution for a Windows service and a Linux demon in .NET/Mono https://github.com/mchudinov/ServiceDemon
And a short blogpost about it