Search code examples
shellcroninclude-path

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


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 something 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!


Solution

  • 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