Search code examples
phplaravelcronqueue

Using laravel queue with cron jobs on shared hosting


In this moment i have a shared hosting server.

In my app i want to use Laravel's queue system, but i can't maintain the command php artisan queue:work beacuse i can't install a supervisor.

With a little bit of an effort, i can move my app on a VPS, but i don't have much of experience with servers and i'm a little scared that my app will be offline much time.

Considering lack of experience on server side, i have this questions:

  1. Is it ok to use Laravel queues with cron jobs? Can it break in any way?
  2. Only for this problem should i upgrade to an VPS or i should remain on this shared hosting server ( i have ssh access here )?

Solution

  • Quick answer: you should not use Laravel queues without a process monitor such as Supervisor.

    It all depends of what you want to achieve, but an alternative to queues would be using the laravel scheduler: you can trigger the scheduler with a cron task (every minute for example), and dispatch jobs easily.

    And if you really want to use the queues, a solution could be to add your jobs to the queue, and process them using a cron task every minute running the following command: php artisan queue:work. But I would recommend the previous solution.