1

I made an cronjob in cpanel for once per minute like this:

enter image description here

and make a command for that like this:

enter image description here

as you see I give the artisan path to that.

and in this path :/home/{projcetname}/laravel/app/Console/Kernel.php I wrote the commands.

but queue table is full.

how can I run queue:work for always ?

thanks

aref razavi
  • 413
  • 2
  • 12

3 Answers3

3

You can create an entry in your kernel.php that regularly starts a queue worker with the --stop-when-empty flag. I wrote this technique up a little while back and have used it effectively on several sites https://talltips.novate.co.uk/laravel/using-queues-on-shared-hosting-with-laravel

Snapey
  • 3,604
  • 1
  • 21
  • 19
  • I followed the instructions. it does not work for me ! where to paste` * * * * * /usr/local/bin/php /home/{account_name}/live/artisan schedule:run` ? – aref razavi Jul 31 '22 at 08:41
  • @arefrazaviyou already did this step in yout original question – Snapey Jul 31 '22 at 09:38
1

How you can run queue:work is the same of how you ran schedule run, Just define a new cron job

* * * * * /usr/local/bin/php /home/sabbabecom/laravel/artisan queue:work --once >/dev/null 2>&1

But when you say always, Does it mean like you want to run it every time it finishes with the current job. If that so then you need to have a supervisor otherwise you can just use the approach i've wrote and it should works fine. At least that what i've understood from your question.

Mohammad.Kaab
  • 1,025
  • 7
  • 20
  • The flaw with this approach is that it can only perform one job per minute (due to --once). If you generate more than 60 jobs per hour, the queue will never empty or will have significant delays. – Snapey Aug 01 '22 at 09:59
0

the problem was about php version I change the php command to this and it's work:

/usr/local/bin/ea-php81
aref razavi
  • 413
  • 2
  • 12