Kritim Yantra
Jul 08, 2025
You're deploying a Laravel project on a shared server using Control Web Panel (CWP). You’ve got jobs queued up — sending emails, processing orders, resizing images...
But you ask yourself:
“How do I run
queue:work
without keeping a terminal open forever?”
Well, you're not alone — and you don’t need Supervisor or a dedicated worker process to handle this. Laravel gives us a neat, cron-based solution that works great even on limited hosting environments.
Let’s walk through it together — step by step, zero confusion, 100% working! 💡
Laravel queues are essential for performance — they allow your app to defer time-consuming tasks like:
But by default, jobs just sit there in the queue.
To process them, you need to run:
php artisan queue:work
But this keeps running forever… which is not practical on shared hosting or CWP. 😩
Here’s the game plan:
queue:work
.Let’s break it down.
routes/console.php
Works beautifully in Laravel 11+, no need to touch
Kernel.php
.
Open this file:
routes/console.php
And add the following at the bottom:
use Illuminate\Support\Facades\Schedule;
use Illuminate\Support\Facades\Log;
Schedule::command('queue:work --stop-when-empty')
->everyFiveMinutes()
->withoutOverlapping()
->before(function () {
Log::info('[Schedule] Queue worker started at ' . now());
})
->after(function () {
Log::info('[Schedule] Queue worker finished at ' . now());
});
queue:work --stop-when-empty
: Processes all pending jobs and exits.everyFiveMinutes()
: Runs every 5 minutes (adjustable).storage/logs/laravel.log
so you can track it.Go to:
CWP ➜ User Panel ➜ Cron Jobs ➜ Add Cron Job
Then use the advanced time options:
📥 Command:
cd /home/appmdlst/public_html/appsys-api && /usr/local/bin/php artisan schedule:run >> /dev/null 2>&1
(Adjust paths based on your Laravel project and PHP location.)
🕐 Time Settings (Advanced):
Minute: */5
Hour: *
Day: *
Month: *
Weekday: *
This tells cron:
Run the Laravel scheduler every 5 minutes.
📌 Description:
Laravel Queue Scheduler (every 5 min)
Click "Save cron" — done! 🎯
Let’s say you dispatch a job like this:
SendWelcomeEmail::dispatch($user);
Laravel pushes it into the queue.
Now, every 5 minutes, the scheduler will:
queue:work
.No manual effort. No supervisor. No hanging terminal. ✅
Here’s a simple test route:
use App\Jobs\SendTestNotification;
Route::get('/test-job', function () {
SendTestNotification::dispatch();
return 'Job dispatched!';
});
Visit /test-job
in the browser.
Wait 1–5 minutes.
Check storage/logs/laravel.log
.
You should see:
[Schedule] Queue worker started at 2025-07-07 15:10:00
[Schedule] Queue worker finished at 2025-07-07 15:10:01
🟢 No jobs?
Even if the queue is empty, Laravel will still runqueue:work --stop-when-empty
, see there’s nothing, and exit. You’ll still get logs.
⚠️ Need faster processing?
Change both the cron and Laravel schedule toeveryMinute()
for near-instant job handling.
💻 PHP path wrong?
Runwhich php
in CWP terminal and replace/usr/local/bin/php
with the correct one.
✅ Why queues matter
✅ How to use Laravel’s scheduler in Laravel 11+
✅ How to schedule queue:work
safely
✅ How to automate it using CWP cron
✅ How to track execution using logs
No need for Supervisor or root access — just clean Laravel + CWP cron power! 🔥
Try this in your Laravel 11+ project and let me know how it works.
Have you used queues before — or is this your first time? Leave a comment below 👇
No worries — queue:work --stop-when-empty
just exits immediately. Logs will still show the run.
Yes — just change everyFiveMinutes()
to everyMinute()
and set your cron time as * * * * *
.
Check storage/logs/laravel.log
. You’ll find entries like:
[Schedule] Queue worker started...
[Schedule] Queue worker finished...
No comments yet. Be the first to comment!
Please log in to post a comment:
Sign in with Google