问题
How to run a scheduled job scripted in php using windows? I'm using Windows XP sp3.
回答1:
Use at
or the task scheduler.
- How To Use the AT Command to Schedule Tasks (seems to require login now - wtf?)
- Alternative: Wikipedia on AT
- How To Schedule Tasks in Windows XP
You would have to call the PHP interpreter from the command line. In Windows, it is called php.exe
. You'll have to find out where it resides, usually in the Programs folder or a sub-directory of your server installation.
The command line for the call will then be something like
"C:\Program Files\Xampp\PHP\PHP.exe" -f "c:\htdocs\my_script_to_run.php"
Note that PHP will probably use a different php.ini
file when called this way, and some variables (like $_SERVER["HTTP_HOST"]
) are not available. This way of running PHP is called CLI (Command Line Interface).
To determine within a PHP script whether it is being run on the Web server or from the command line, use php_sapi_name().
回答2:
Note that PHP will probably use a different php.ini file when called this way, and some variables (like $_SERVER["HTTP_HOST"]) are not available. This way of running PHP is called CLI (Command Line Interface).
来源:https://stackoverflow.com/questions/2491378/cron-jobs-in-php-deployed-in-windows-platform