php cli 方式 在crotab中运行解决

前端之家收集整理的这篇文章主要介绍了php cli 方式 在crotab中运行解决前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

<div class="codetitle"><a style="CURSOR: pointer" data="15301" class="copybut" id="copybut15301" onclick="doCopy('code15301')"> 代码如下:

<div class="codebody" id="code15301">
/var/www/html/bt/e/BtSys:.:/usr/share/pear:/usr/share/PHPPHP Warning: require(../class/connect.PHP): Failed to open stream: No such file or directory in /var/www/html/bt/e/BtSys/torrents-scrape.PHP on line 17
PHP Fatal error: require(): Failed opening required '../class/connect.PHP' (include_path='/var/www/html/bt/e/BtSys:.:/usr/share/pear:/usr/share/PHP') in /var/www/html/bt/e/BtSys/torrents-scrape.PHP on line 17

尝试解决方法1 加入如下代码 代码
<div class="codetitle"><a style="CURSOR: pointer" data="7015" class="copybut" id="copybut7015" onclick="doCopy('code7015')"> 代码如下:
<div class="codebody" id="code7015">
// setting include path
$cur_dir=getcwd();
$cur_dir=$basedir = dirname(FILE);
$path = ini_get('include_path');
ini_set("include_path","$cur_dir:$path");
$path = ini_get('include_path');
//echo $path;
require(../class/a.PHP)
require(../class/b.PHP)
...............

运行失败 尝试解决方法2 加入如下代码
<div class="codetitle"><a style="CURSOR: pointer" data="84988" class="copybut" id="copybut84988" onclick="doCopy('code84988')"> 代码如下:
<div class="codebody" id="code84988">
$cur_dir = dirname(FILE);
chdir($cur_dir);
require(../class/a.PHP)
require(../class/b.PHP)

运行成功
总结: 在require 时,如果是相对目录,在crontab 中运行PHP脚本,要进入到脚本所在目录才可以

原文链接:https://www.f2er.com/php/28816.html
cliclicliphp

猜你在找的PHP相关文章