windows 使用任务计划程序每 4 小时运行一次脚本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21240656/
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
run a script every 4 hours with task scheduler
提问by jim smith
I have windows 2008 task scheduler I set up a PHP script to run like this
我有 Windows 2008 任务调度程序,我设置了一个 PHP 脚本来像这样运行
C:\php\php.exe -f etc...
C:\php\php.exe -f 等...
In windows task scheduler I can only schedule daily or hourly how can I configure it to run every 4 hours?
在 Windows 任务计划程序中,我只能每天或每小时安排一次如何将其配置为每 4 小时运行一次?
回答by Mikhail
In Windows Server 2008/2008R2 you can set task to repeat every number of hours you want, corresponding drop down menu just present you with 1 hour option to select, but you can type in any number of hours you need (see screenshot below).
在 Windows Server 2008/2008R2 中,您可以将任务设置为每隔几小时重复一次,相应的下拉菜单仅显示 1 小时选项供您选择,但您可以输入您需要的任意小时数(请参见下面的屏幕截图)。
回答by Gerrat
You could just set it up to run every hour, and at the beginning of the PHP script, check the current time, and exit if the current hour modulus 4 wasn't zero.
您可以将它设置为每小时运行一次,并在 PHP 脚本的开头检查当前时间,如果当前小时模数 4 不为零则退出。
Where it says "repeat task every", you may also just be able to change "1 hour" to "4 hours" (it's not in the dropdown, so just type it in). You can do this in Windows 7, I'm not sure about Windows Server 2008.
在它说“重复任务间隔”的地方,您也可以将“1 小时”更改为“4 小时”(它不在下拉列表中,因此只需输入)。您可以在 Windows 7 中执行此操作,我不确定 Windows Server 2008。