在 Windows Server 2003 上设置 PHP cron 作业

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

Set PHP cron job on windows server 2003

phpwindowsscheduled-taskscron

提问by windowsdummy

I am using Windows server 2003, IIS6, php and mysql. I have a problem setting the cronjob using built in schedule task feature in Windows OS.

我使用的是 Windows Server 2003、IIS6、php 和 mysql。我在使用 Windows 操作系统中的内置计划任务功能设置 cronjob 时遇到问题。

  • Start > Programs > Accessories > System Tools > Schedule Tasks

  • Add "new schedule task"

  • It asks me choose programs. Should I choose php.exe or internet explorer, because php files run on internet browser right? How do I call the specific php files (assume the name of the file is cronjob.php)

  • 开始 > 程序 > 附件 > 系统工具 > 计划任务

  • 添加“新计划任务”

  • 它要求我选择程序。我应该选择 php.exe 还是 Internet Explorer,因为 php 文件可以在 Internet 浏览器上运行,对吗?如何调用具体的php文件(假设文件名是cronjob.php)

I need your guys help. Please advise.

我需要你们的帮助。请指教。

回答by Greg Ellis

if you would like to run the scheduled task every minute you have to set it up through the command like as follows:

如果您想每分钟运行一次计划任务,您必须通过如下命令进行设置:

schtasks /create /sc minute /mo 1 /tn "my task" /tr "C:\Program Files\php5\php.exe c:\wwwroot\inetpub\website\myfile.php?task=fetch"

This will let you run the task each minute. There is no way to do this through to the task scheduler gui to my knowledge so I just wanted to share this solution.

这将使您每分钟运行一次任务。据我所知,没有办法通过任务调度程序 gui 来做到这一点,所以我只想分享这个解决方案。

回答by windowsdummy

You'll need to call php.exe as the interpreter with the path to the script as its argument, example:

您需要调用 php.exe 作为解释器,并将脚本路径作为其参数,例如:

"c:\program files\php5\php.exe" c:\cronscripts\cronjob.php

That should work.

那应该有效。

回答by Andy

You call

你打电话

php.exe cronjob.php