I have a MAMP setup which runs PHP 5.3.5 on my Mac OS X 10.5 computer. I am trying to install a crontab that executes a PHP script, which is located on my MAMP server. I can only get the crontab to execute if I use the php installation from /usr/bin/php, which is version 5.2.15. In other words, this is the pre-installed MAC OS X installation of PHP. How can I use my MAMP's version of PHP when executing the crontab? I am not knowledgeable enough with unix to install a new version of PHP at /usr/bin/php, though would this work?
I want crontab to execute my PHP script using MAMP's version of PHP; this is because I know that the script runs successfully, and I get the desired output. However, when I try executing the crontab using the system default PHP installation at /usr/bin/php, I get Fatal PHP errors.
In case this might be useful, here is the outcome of /usr/bin/php vs. MAMP's version. The first code example executes my php script successfully:
$ MAMP_PHP_PATH="/applications/mamp/bin/php5.3/bin/php" $ $MAMP_PHP_PATH -f /path/to/my/script.php
Now, here's what happens when I simply run the following command:
$ # whereis php in this case returns usr/bin/php $ php -f /path/to/my/script.php
Results in the following error (formatting mine):
Fatal error: require_once(): Failed opening required '/path/to/includes/initialize.php' (include_path='.:') in /path/to/my/script.php on line 3
Finally, this is what my crontab file looks like (with MAMP's php):
15 * * * * /Applications/MAMP/bin/php5.3/bin/php /path/to/my/script.php
And without MAMP's php:
15 * * * * php /path/to/my/script.php