简体   繁体   English

cURL在Windows Task Scheduler中不起作用

[英]cURL not working in Windows Task Scheduler

I've a PHP script that uses cURL to perform certain tasks. 我有一个使用cURL执行某些任务的PHP脚本。 At the moment, I have the script running every 10 minutes. 此刻,我每10分钟运行一次脚本。 This is what I'm running via Windows Task Scheduler. 这就是我通过Windows Task Scheduler运行的内容。

C:\\wamp\\bin\\php\\php5.4.3\\php.exe -f C:\\wamp\\www\\autoscripts\\index.php C:\\ wamp \\ bin \\ php \\ php5.4.3 \\ php.exe -f C:\\ wamp \\ www \\ autoscripts \\ index.php

However, for some reason, whenever the argument quoted above is run through the command line, I get the error "Fatal error: Call to undefined function curl_init()". 但是,由于某种原因,每当上面引用的参数通过命令行运行时,都会出现错误“致命错误:调用未定义的函数curl_init()”。 The script works perfectly when I access it via the browser. 当我通过浏览器访问脚本时,该脚本可以完美运行。 Is there any reason why PHP isn't able to access the cURL extension via the command line? 有什么原因导致PHP无法通过命令行访问cURL扩展名?

Most likely running from command line does not use any ini file that loads the extensions. 从命令行运行很可能不使用任何加载扩展名的ini文件。 Open phpinfo() from the browser, copy path to loaded ini file and change your task to: 从浏览器中打开phpinfo() ,将路径复制到已加载的ini文件,并将您的任务更改为:

C:\wamp\bin\php\php5.4.3\php.exe -c "C:\path\to\php.ini" -f C:\wamp\www\autoscripts\index.php

Figured it out. 弄清楚了。 Basically, on WampServer, there are TWO php.ini files that you need to be aware of. 基本上,在WampServer上,您需要了解两个php.ini文件。

  • C:\\wamp\\bin\\php\\php5.4.3\\php.ini C:\\ WAMP \\ BIN \\ PHP \\ php5.4.3 \\ php.ini中
  • C:\\wamp\\bin\\apache\\apache2.2.22\\bin\\php.ini C:\\ WAMP \\ BIN \\ apache的\\ apache2.2.22 \\ BIN \\ php.ini中

Forgot that the command line uses a different ini file than the web server. 忘记了命令行使用与Web服务器不同的ini文件。 :( :(

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

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