我试图通过cron job运行一个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都是现有文件,并且位于正确的位置,是什么?
由于
答案 0 :(得分:10)
看起来你的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
答案 1 :(得分:0)
请参阅此问题:PHP: Require path does not work for cron job?
您的include_path不包含您正在执行的脚本的路径。