2

我正在尝试通过 cron 作业运行一个 php 文件,当我手动运行它时该文件工作正常,但是当我在 cron 作业中运行它时,我收到此错误:

Warning: include(classes/EmailAddressValidator.php): failed to open stream: No such file or directory in /var/www/onecent_dev/classes/MiscFunctions.php on line 3

Warning: include(): Failed opening 'classes/EmailAddressValidator.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/onecent_dev/classes/MiscFunctions.php on line 3

MiscFunctions.php 和 EmailAddressValidator.php 都是现有文件并且位于正确的位置,有什么用?

谢谢

4

2 回答 2

11

看起来您的 include_path 正在解析。到任何 cron 碰巧将当前目录设置为,而不是脚本所在的目录。尝试先将您的 crontab 编辑为 cd:

0 * * * * cd /path/to/script && php script.php

或明确提供 include_path:

0 * * * * php -d include_path=/path/to/script script.php
于 2012-04-17T15:46:36.347 回答
0

看到这个问题:PHP:要求路径不适用于 cron 作业?

您的 include_path 不包含您正在执行的脚本的路径。

于 2012-04-17T15:46:30.040 回答