【发布时间】:2013-06-04 08:34:06
【问题描述】:
我有一个脚本,我们称它为 mainfile.php,其中包含同一目录中的文件。我将其包括如下:
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once './myincludefile.php';
?>
如果我执行以下操作:
nohup php mainfile.php >/dev/null
它运行没有任何问题。但是,如果将其转换为 cron 作业,我会收到以下消息(在我的邮件假脱机中):
PHP Warning: require_once(./myincludefile.php): failed to open stream: No such file or directory in /home/code/mainfile.php on line 5
PHP Fatal error: require_once(): Failed opening required './myincludefile.php' (include_path='.:/usr/share/pear:/usr/share/php') in/home/code/mainfile.php on line 5
有什么想法吗?
【问题讨论】:
-
通过 cron 运行任务时,您必须始终在脚本中指定完整路径。