views:

28

answers:

2

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!

+1  A: 

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

ennuikiller
I'm getting several of 2 different kinds of error messages: `PHP Warning: include(lib/File.php): failed to open stream: No such file or directory in /var/www/vhosts/***/other_file.php on line 28``PHP Warning: include(): Failed opening 'lib/File.php' for inclusion (include_path='.:') in /var/www/vhosts/***/other_file.php on line 28`I'm going to work on the include_path and I'll let you know. Thx
bradenkeith
For some reason when root was accessing it, it set the file path to /root/ instead of /var/www... So I had to manually define all the absolute file paths. Blah, ugly ugly fix. If anyone has a better way, I'd love to hear.
bradenkeith
A: 

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

TheOmniarch