Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

nhayder's avatar
Level 13

How to run queues on shared hosting

i have an app hosted on a cPanel dedicated hosting account and i need to setup a cron jobs to run my laravel queues.

this is the first time i do this type of implementation so i needed some help to understand how to do this type of implementation.

The queues are fully working as expected on my local computer so the laravel part of this implementation is done :-) and on cPanel ??? i can create a cron job to run every minute.

But my question is, how to run php artisan queue:work from cPanel cron job, so my worker can process queued tasks

any ideas

0 likes
11 replies
tykus's avatar

i need to setup a cron jobs to run my laravel queues

Schedule Job !== Queue Worker

It is very unlikely that your hosting provider will allow shell access to run the queue worker.

1 like
nhayder's avatar
Level 13

Yah but again i can SSH into the APP and simply type

php artisan queue:work

This will run the queue and it will stay working as long as the app is alive ???

what does everybody think of implementation this ????

Snapey's avatar

It will keep running until it crashes (which it may not). There are some suggestions around about restarting the queue worker with a cron job, eg every hour. Alternatively, run the queue until it is empty then start if again after a delay using a cron job (say, every 5 minutes).

Can you setup cron job?

1 like
Snapey's avatar

How important is having the queue run continuously? Could there be gaps?

having cron job of php artisan queue:work --stop-when-empty can run, empty the queue, then die. How often you repeat this depends how busy the queue is.

1 like
nhayder's avatar
Level 13

@snapey just want to clarify the process here,

So let's say the cron job has started and it triggered the queue to process tasks

this will stop die/ kills the queue when they are empty

php artisan queue:work --stop-when-empty

then after lets say 1 minute the cron job will start another queue and it will die when the queue is empty.

is that what your saying @snapy ????

if yes that would be really good implementation to do.

did i understood you correctly ???

your question : How often you repeat this depends how busy the queue is.

my answer : i think a frequency of every minute will be fine

Snapey's avatar
Snapey
Best Answer
Level 122

A couple of things

  • your cpanel cron could run the queue worker directly, (you don't need to do this with the laravel scheduler)

  • if your queue is quite full, and has not finished processing all jobs after one minute, then a second queue worker would be started. I cant really think of any negatives to this but you should watch out for the same job being executed twice.

1 like
nhayder's avatar
Level 13

@snapey thank you for the informative replays, I will try this and let you know if there is any further help

nhayder's avatar
Level 13

@snapy you wrote

your cpanel cron could run the queue worker directly, (you don't need to do this with the laravel scheduler

how can cpanel could run a queue worker directly, Do you mean on a seperate route (auth route) where i can create new controller containing logic ??

myapp.com/admin/cronjobs // cron can hit this route

// in cronController i can do this
Artisan::call('queue:work --stop-when-empty');

can you expand on this note please, most likely i'm moving in this direction (without laravel scheduler )

Snapey's avatar

Im assuming your cron configuration can run jobs without being a web route?

Please or to participate in this conversation.