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
Embark on a journey of knowledge! Take the quiz and earn valuable credits.
Take A QuizChallenge yourself and boost your learning! Start the quiz now to earn credits.
Take A QuizUnlock your potential! Begin the quiz, answer questions, and accumulate credits along the way.
Take A QuizGeneral Tech Bugs & Fixes 2 years ago
Posted on 16 Aug 2022, this text provides information on Bugs & Fixes related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for 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.
General Tech 10 Answers
General Tech 7 Answers
General Tech 3 Answers
General Tech 9 Answers
Ready to take your education and career to the next level? Register today and join our growing community of learners and professionals.
manpreet
Best Answer
2 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