0

好吧,我正在尝试运行一个包含一些文件的 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

4

1 回答 1

1

You need to "posicionate" in yor directory first or use absolute path in your includes. Try changing your command to this:

cd /home/xxxxx/public_html/cron && /usr/local/bin/php /home/xxxxx/public_html/cron/somefile.php
于 2013-01-02T20:45:26.287 回答