Cron’s php script pathing issue
Php include/require pathing is related to how you run your script in cron for example you are having a PHP script in /var/www/html/phpscript/project1/index.php , And below is how the scripts include the files
<?php include("../include_1.php"); include("../include_2.php"); ?>
and below is how you run your script in cron.
* * * * * php /var/www/html/phpscript/project1/index.php
The case above will not work because cron is running in root’s home folder. There are alternative ways to solve this problem.
1. Cd into the path then run the script as below:-
* * * * * cd /var/www/html/phpscript/project1/; php index.php
2.To Standarize to use full path in every related script (Not Recommended)
I strongly suggest method 1 because it is easier to handle and if there is changes in phpscript about the pathing you won’t have to change every related script.