我正在尝试运行包含一些文件的cronjob,但是当我通过命令行运行它时,它一直说文件不存在
这是php文件:
include "../includes/common.php";
require_once('../anotherfile.php');
require_once '../swift/lib/swift_required.php';
//some database things
这是我运行的命令行:
/usr/local/bin/php /home/xxxxx/public_html/cron/somefile.php
这是我得到的错误:
Warning: include(..includes/common.php): failed to open stream: No such file or directory in /home/xxxxx/public_html/cron/somefilek.php on line 3
Warning: include(..includes/common.php): failed to open stream: No such file or directory in /home/xxxxx/public_html/cron/somefilek.php on line 3
Warning: include(): Failed opening '..includes/common.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/xxxxx/public_html/cron/somefilek.php on line 3
Warning: require_once(..anotherfile.php): failed to open stream: No such file or directory in /home/xxxxx/public_html/cron/somefilek.php on line 4
Fatal error: require_once(): Failed opening required '..anotherfile.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/xxxxx/public_html/cron/somefilek.php on line 4
由于某种原因,它没有说明swift_required.php
答案 0 :(得分:1)
您需要先在目录中“posicionate”,或在包含中使用绝对路径。尝试将命令更改为:
cd /home/xxxxx/public_html/cron && /usr/local/bin/php /home/xxxxx/public_html/cron/somefile.php