I have the following inside my crontab -e
0,30 * * * * cd /usr/local/bin && php /var/www/artisan my_command > /var/www/storage/logs/cron.log 2>&1
But I get the following inside /var/www/storage/logs/cron.log
.
/bin/sh: 1: php: not found
I tried running the following for reference:
# which php
/usr/local/bin/php
# whoami
root
I am running cron from inside a docker image (OS: Ubuntu) in a Laravel project.
I tried changing the path in different ways, but it still gave the same error.
There were a lot of similar questions, but I didn't manage to find my answer...
CodePudding user response:
The current directory isn't in the PATH
(and it shouldn't be).
Simply skip the useless cd
command and run /usr/local/bin/php
instead:
0,30 * * * * /usr/local/bin/php /var/www/artisan my_command > /var/www/storage/logs/cron.log 2>&1