开发者

include(): Failed opening when accessing by Shell/Crontab

开发者 https://www.devze.com 2023-01-12 20:45 出处:网络
I\'m setting up a crontab. When accessing the php file directly (domain.com/file-path/file.php) it works perfectly. When accessing it through shell (php -f /var/www/vhosts/domain.com/file-path/file.ph

I'm setting up a crontab. When accessing the php file directly (domain.com/file-path/file.php) it works perfectly. When accessing it through shell (php -f /var/www/vhosts/domain.com/file-path/file.php) I get include file errors all over the place. It has somet开发者_开发百科hing to do with the include path being set as: (include_path='.:')

Is there an argument I can pass through shell to set the include_path? Or is there something I can put in file.php to fix the error? I'm trying to avoid going through all documents related to this and fixing the include path to be absolute.

Thanks!


try duplicating your login environment by sourcing all profile files, or see what include_path is current set to and set it appropriately in the before using php. Either method will require you to write a short script


You could modify your cron entry to first change to the appropriate directory and then execute the command:

cron: * * * * * cd /home/user/rest/of/path ; /usr/local/bin/php file.php
0

精彩评论

暂无评论...
验证码 换一张
取 消