Win32 中的计划任务
我在 WinXP SP2 计算机上有一个计划任务,设置为运行 python 脚本:
每日
开始时间: 上午 12:03
每日计划任务:< /strong> 每 1 天
开始日期: 过去的某个时间
重复任务: 每 5 分钟
直到:持续时间 24 小时
基本上,我想要脚本每五分钟运行一次,永远。
我的问题是该任务每天晚上 23:47 之后运行(大概是 23:55 之后),并且在那之后不再运行。我做错了什么?或者,除了使用 Windows 计划任务之外,您还可以建议其他方法吗?
I have a Scheduled Task on a WinXP SP2 machine that is set up to run a python script:
Daily
Start time: 12:03 AM
Schedule task daily: every 1 day
Start date: some time in the past
Repeat task: every 5 minutes
Until: Duration 24 hours
Basically, i want the script to run every five minutes, for ever.
My problem is the task runs sometime after 23:47 every night (presumably after 23:55) and does not run after that. What am I doing wrong? Alternatively, is there a different method you can suggest other than using Windows scheduled tasks?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
在第一个窗格(标记为“任务”)上,您是否未选中“仅在登录时运行”并选中“已启用(计划任务在指定时间运行)”?
我已经通过 Windows 计划任务运行 python 作业,其设置非常类似于你展示。
On the first pane (labeled "Task") do you have "Run only if logged on" unchecked and "Enabled (scheduled task runs at specified time" checked?
I've run python jobs via Windows scheduled task with settings very similar to what you show.
另外,在过去一年左右的时间里,我发现了一个常见错误,如果选中以下任一复选框,则 Server 2003 或 XP 上的计划任务不会运行:
如果您有电池(在笔记本电脑上)或 UPS(例如在服务器上),无论您的市电是否正常工作,Windows 似乎都会有点困惑。
另外,作为一项规则,当您经常运行任务时,我会缩短时间或取消选中“如果任务运行 X 分钟则停止任务”选项。
Also, for the past year or so I've seen a common bug where Scheduled Tasks on Server 2003 or XP do not run if either of the following checkboxes are on:
It seems that Windows gets a little confused if you have a battery (on a laptop) or a UPS (on a server, for example), whether or not your utility power is working.
Also, as a rule I would trim down the time or uncheck the option to "Stop the task if it runs for X minutes" when you're running it so often.
据我所知,计划任务很糟糕。您应该使用具有更好控制能力的东西,例如
http://cronw.sourceforge.net/ 或任何其他实现Windows 的 cron。
From what I know, Scheduled Tasks is horrible. You should use something with better control like
http://cronw.sourceforge.net/ or any other implementation of cron for Windows.
直到:持续时间 24 小时
第一天结束时将其关闭。
把它去掉,看看是否还能继续。应该可以,而且您不需要在此过程中安装 Python。 :)
Until: Duration 24 hours
That shuts it off at the end of the first day.
Remove that, see if it keeps going. It should, and you shouldn't need to install Python in the process. :)
冒着不回答您问题的风险,我可以建议,如果您必须运行的内容很重要甚至至关重要,那么 Windows 任务计划程序不是运行它的方式。
使用任务调度程序时有很多糟糕的流程。让我们从明显的开始:
没有日志记录。没有办法调查出现问题时会发生什么。无法跨 PC 分配工作。没有容错能力。它仅适用于Windows,而且界面很糟糕。
如果以上任何一个对您来说是个问题,您需要一些更复杂的东西。我的建议是您尝试 Hudson,又名 Sun 的持续集成服务器。
除了上述所有功能之外,它还可以进行 cron 式调度,并具有日志自动过期功能。它可以设置为失败时发送 jabber 或电子邮件,如果您可以让它生成一些 XML 输出,您甚至可以让它自动诊断您的流程出了什么问题。
请不要使用 Windows 计划任务。有很多更好的东西可以使用,当我说我从不后悔放弃内置调度程序时,我是根据经验说话的。
At the risk of not answering your question, can I suggest that if what you have to run is important or even critical then Windows task-Scheduler is not the way to run it.
There are so many awful flows when using the task-scheduler. Lets just start with the obvious ones:
There is no logging. There is no way to investigate what happens when things go wrong. There's no way to distribute work across PCs. There's no fault-tolerance. It's Windows only and the interface is crappy.
If any of the above is a problem for you you need something a bit more sophisticated. My suggestion is that you try Hudson, a.k.a. Sun's continuous integration server.
In addition to all of the above it can do cron-style scheduling, with automatic expiry of logs. It can be set to jabber or email on failure and you can even make it auto diagnose what went wrong with your process if you can make it produce some XML output.
Please please, do not use Windows Scheduled tasks. There are many better things to use, and I speak from experience when I say that I never regretted dumping the built-in scheduler.
您运行的 Windows 版本是什么?
您是否检查了“设置”选项卡以确保取消选择所有选项?
您还可以考虑使用功能更丰富的调度程序,例如 Splinterware Software 的系统调度程序
What version of Windows are you running?
Did you check the "Settings" tab to make sure all of the options are de-selected?
You might also consider a more feature rich scheduler such as System Scheduler from Splinterware Software
您可以从另一个脚本安排它,并每天或每次重新启动后启动一次:
这样您也可以执行亚分钟的间隔。
you can schedule it from another script and kick this off once a day or after each reboot:
This way you can do sub-minute intervals also.