CRON作业在php中部署在windows平台 [英] CRON jobs in php deployed in windows platform

查看:247
本文介绍了CRON作业在php中部署在windows平台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用Windows运行使用php脚本的计划作业?

How to run a scheduled job scripted in php using windows? I'm using Windows XP sp3.

推荐答案

使用任务调度程序。

  • 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

PHP解释器从命令行。在Windows中,它被称为 php.exe 。您必须找到它驻留的位置,通常在程序文件夹或服务器安装的子目录中。

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"

请注意,PHP可能会使用不同的 php.ini 文件,并且一些变量(如 $ _ SERVER [HTTP_HOST] )不可用。这种运行PHP的方式称为CLI(命令行界面)。

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

要在PHP脚本中确定它是在Web服务器上运行还是从命令行运行,请使用 php_sapi_name()

To determine within a PHP script whether it is being run on the Web server or from the command line, use php_sapi_name().

这篇关于CRON作业在php中部署在windows平台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆