Linux – Problems with running a PHP file to include directories via Linux

cronlinuxPHP

I'm running a Centos 5 server and want to set up a cronjob to run on every 10th of each month, but I have to following concern.

The PHP file that I need to run sits in /var/www/html/test/ called sendMails.php

If I go to the test directory eg. cd /var/www/html/test and type in ./sendMails.php my script runs perfect.

In the test directory is a folder called template and in the template folder is a file with the name index.htm. index.htm is being read in sendMails.php via the php function file_get_contents .

Now I run the script from my home directory eg. php /home/roland/sendMails.php and I get the following error file_get_contents(template/index.htm): failed to open stream: No such file or directory and don't understand why, now this will then also fail if I setup a cron.

Any advise will be appreciated

Best Answer

Have you moved the template directory too?

You are better to put the files somewhere and make the script your absolute paths. E.g. /path/to/your/script.php and in the script include(/path/to/your/include/dir/index.html)

Related Topic