Search code examples
phplaravelcroncpanel

Executing laravel commands in cron as a shell command


I'm using cPanel to create a cron like so :

* * * * * /home/elsdqscy/folder/update_db.sh > update_db.txt

Inside my shell file I have :

#!/bin/bash

cd folder && php artisan migrate:fresh --seed --force

This should work, knowing that the command /home/elsdqscy/folder/update_db.sh works in the terminal.

I do get this error in the output file:

In ArgvInput.php line 246:
                                           
  Invalid argument supplied for foreach()  

Content-type: text/html; charset=UTF-8

Any idea what am I doing wrong?


Solution

  • You need to provide the full path inside your shell file as well, like so:

    cd folder && /usr/bin/php artisan migrate:fresh --seed --force