Cron job fail to include files

If you select php as the command language for your cron job, relative paths may not work. This is because some PHP scripts expect to be run from the directory where they are stored, and due to the nature of our Sites platform they will be run from another location. This means including or requiring files from a relative path may result in errors such as:

 PHP Warning: include(../dbconnection.php): failed to open stream: No such file or directory
Solution

To correct this problem, you could use the absolute path to reference any files in your script. An absolute include looks something like this:

include('/var/www/html/dbconnection.php');

Leave a Reply

Your email address will not be published. Required fields are marked *