Set the environment variables you need in the crontab. For example:
PATH=/Applications/MAMP/bin/php5.3/bin:/usr/local/bin:/usr/bin:/bin
MAMP_PHP_PATH=/applications/mamp/bin/php5.3/bin/php
15 * * * * php /path/to/my/script.php
Kindly log in to use this feature. We’ll take you to the login page automatically.
LoginGeneral Tech Bugs & Fixes 3 years ago
User submissions are the sole responsibility of contributors, with TuteeHUB disclaiming liability for accuracy, copyrights, or consequences of use; content is for informational purposes only and not professional advice.
Set the environment variables you need in the crontab. For example:
PATH=/Applications/MAMP/bin/php5.3/bin:/usr/local/bin:/usr/bin:/bin
MAMP_PHP_PATH=/applications/mamp/bin/php5.3/bin/php
15 * * * * php /path/to/my/script.php
No matter what stage you're at in your education or career, TuteeHUB will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.
Kindly log in to use this feature. We’ll take you to the login page automatically.
LoginReady to take your education and career to the next level? Register today and join our growing community of learners and professionals.
Your experience on this site will be improved by allowing cookies. Read Cookie Policy
Your experience on this site will be improved by allowing cookies. Read Cookie Policy
manpreet
Best Answer
3 years ago
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:
Now, here's what happens when I simply run the following command:
Results in the following error (formatting mine):
Finally, this is what my crontab file looks like (with MAMP's php):
And without MAMP's php:
Thanks