Set PHP cron job on windows server 2003

2020-05-24 20:42发布

问题:

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.

  • 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)

I need your guys help. Please advise.

回答1:

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.



回答2:

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

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

That should work.



回答3:

You call

php.exe cronjob.php