Search code examples
laravelcronlaravel-artisanbitnami

Unable to run PHP Artisan command using Cron on Bitnami LAMP stack


I've created a custom Laravel PHP Artisan command which I was intending to use together with a cron job to carry out automated tasks on my server.

However, I'm having problems running the script and have tried a whole bunch of variations without much luck. Have looked high and low on the inter webs can't find anything to remedy my problems...

Here are a few of them:

* * * * * sudo su daemon -s /bin/sh -c "/opt/bitnami/php/bin/php /opt/bitnami/apps/demo/htdocs/ && php artisan schedule:run >> /tmp/output.txt 2>&1"


* * * * * cd /opt/bitnami/apps/demo/htdocs/ && php artisan schedule:run >> /tmp/output.txt 2>&1


* * * * * /opt/bitnami/php/bin/php /opt/bitnami/apps/demo/htdocs/ && php artisan schedule:run >> /tmp/output.txt 2>&1

The error I keep getting is: "/bin/sh: 1: php: not found"

I've also tried to execute the command as Bitnami, but no luck there either.


Solution

  • Thanks Jota, I ran the following and it seemed to have done the job:

    * * * * * cd /opt/bitnami/apps/demo/htdocs/ && /opt/bitnami/php/bin/php artisan schedule:run >> /tmp/cron_output_8.txt 2>&1
    

    Got this message instead now:

    No scheduled commands are ready to run.

    Which is good, I think that's just laravel, and I haven't set all that stuff up to run at this point.

    Cheers, Mikael