Windows 上的每小时定时任务

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1192580/
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-15 12:52:49  来源:igfitidea点击:

Hourly cronjob on Windows

windowscrontab

提问by KB22

I just setup cron on my windows dev system in order to perform an hourly run of a script.

我只是在我的 Windows 开发系统上设置了 cron,以便每小时运行一次脚本。

I tried to edit crontab in order to run my script hourly, sadly with no success.

我试图编辑 crontab 以便每小时运行我的脚本,遗憾的是没有成功。

Could anyone pls. drop me the crontab line which will execute script.xy every hour?

任何人都可以请。给我一个 crontab 行,它将每小时执行一次 script.xy?

回答by Jan

If you're using Windows, why not use the built-in Scheduled Tasks (Accessories-System Tools)?

如果您使用的是 Windows,为什么不使用内置的计划任务(附件 - 系统工具)?

It may not show up immediately in the Wizard, but it is possible to set up tasks to be run hourly. Just add a daily task and then tick the "Open Advanced Properties" checkbox. Then go to the Schedule tab and again click "Advanced".

它可能不会立即显示在向导中,但可以将任务设置为每小时运行一次。只需添加一个日常任务,然后勾选“打开高级属性”复选框。然后转到“计划”选项卡并再次单击“高级”。

回答by KB22

I figured it out: 0 * * * * C:\doSomeWork.script Makes the script run every full hour. Sometimes the easy way is the best... ;) thx anyway

我想通了: 0 * * * * C:\doSomeWork.script 使脚本每完整小时运行一次。有时简单的方法是最好的...... ;) 无论如何

回答by Mike McQuaid

I'd argue you probably don't want to be using Cron on Windows at all. Instead use a Scheduled Task (accessible through the Control Panel) and select your script.

我认为您可能根本不想在 Windows 上使用 Cron。而是使用计划任务(可通过控制面板访问)并选择您的脚本。

Alternatively create a Windows service which runs your program hourly. I've never heard of people using Cron for Windows tasks in this way.

或者,创建一个每小时运行您的程序的 Windows 服务。我从未听说过有人以这种方式将 Cron 用于 Windows 任务。

回答by Ola Herrdahl

Can't you use the Windows Task Schedulerinstead of crontab? A commandline solution would look something like:

您不能使用Windows 任务计划程序而不是 crontab 吗?命令行解决方案如下所示:

at 00:00 /EVERY:M,T,W,Th,F,S,Su yourScript.cmd
at 01:00 /EVERY:M,T,W,Th,F,S,Su yourScript.cmd
...

Notice that you have to schedule a new task for each hour. Anyone got a better soluition for this using the at command?

请注意,您必须为每个小时安排一个新任务。有没有人使用 at 命令对此有更好的解决方案?