尝试运行包含文件的cronjob,但是当我运行命令行时,它继续说有错误,文件不在那里

时间:2013-01-02 20:42:16

标签: php shell cron

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

1 个答案:

答案 0 :(得分:1)

您需要先在目录中“posicionate”,或在包含中使用绝对路径。尝试将命令更改为:

cd /home/xxxxx/public_html/cron && /usr/local/bin/php /home/xxxxx/public_html/cron/somefile.php