CRON jobs in php deployed in windows platform

让人想犯罪 __ 提交于 2020-01-17 07:50:08

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!