简体   繁体   English

在Windows Server 2003上设置PHP cron作业

[英]Set PHP cron job on windows server 2003

I am using Windows server 2003, IIS6, php and mysql. 我使用的是Windows Server 2003,IIS6,php和mysql。 I have a problem setting the cronjob using built in schedule task feature in Windows OS. 我在使用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? 我应该选择php.exe或Internet Explorer,因为php文件在互联网浏览器上运行吗? How do I call the specific php files (assume the name of the file is cronjob.php) 如何调用特定的php文件(假设文件的名称是cronjob.php)

I need your guys help. 我需要你的帮助。 Please advise. 请指教。

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这样做,所以我只想分享这个解决方案。

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. 这应该工作。

你打电话

php.exe cronjob.php

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM