I have a cron job set up to run testemail.php. This works fine, every minute. (Ubuntu localhost, php5)
* * * * * /usr/bin/php5 -q /var/www/cocoraco/portfolio/html/testemail.php > /dev/null 2>&1
I have a second file findandemail.php which runs some Database tasks and sends email. The email function is defined in (and I did include it as follows) "../scripts/functions.php". It does not work, while the testemail.php still works.
Cron in this case looks like
* * * * * /usr/bin/php5 -q /var/www/cocoraco/portfolio/html/testemail.php > /dev/null 2>&1
* * * * * /usr/bin/php5 -q /var/www/cocoraco/portfolio/find/findandemail.php > /dev/null 2>&1
As a test, If i copy code from testemail.php to findandemail.php, that section runs fine sending a dummy email. I am new to cron.
Can anyone shed some light? Thanks in advance.
When executing code like this your code runs at
/usr/binso if youinclude ../scripts/functions.phpyour code looks for the file at/usr/scripts/functions.phpI like to use the
__FILE__magic constant to include files very bulletproof:This should do the trick for you.