Forum Moderators: coopster

Message Too Old, No Replies

Trouble including relative PHP files from cron jobs

         

smithaa02

9:41 pm on Nov 29, 2006 (gmt 0)

10+ Year Member



I have a php file /home/mysite.com/httpdocs/admin_section/report.php that as part of the script includes another file ../connections/connect.php.

Report.php works perfectly when I open it from a webbrowser (mysite.com/admin_section/admin.php), but when I run from my crontab or command line via:

# /usr/bin/php /home/mysite.com/httpdocs/admin_section/report.php

The report.php file then chokes on the include.

"PHP Warning: main(../connections/connect.php): failed to open stream: No such file or directory in..."

And the strange thing is this used to work before my server was upgraded by tech support. If I get rid of the relative path and include the full server path to connect.php, it works perfectly (but because I have a number of scripts like this, it isn't practical for me to change any of the PHP code).

Any ideas on how I can fix this?

Any ideas on what could be causing this?

justageek

9:53 pm on Nov 29, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The cron job is running from a different directory? Maybe put the full path in the include?

JAG

smithaa02

10:54 pm on Nov 29, 2006 (gmt 0)

10+ Year Member



^ In my case this wouldn't be practical.

Found the problem... A module called php-suhosin was the issue.