Software
Laravel Queues and Cron on Shared Hosting: What Actually Works
No Supervisor, no root, disabled PHP functions — and still a reliable background job system.
Laravel's documentation assumes you can run a long-lived queue worker under a process manager like Supervisor. On a VPS that's easy. On shared hosting — still the cheapest way to put a Laravel app online — you usually can't.
That doesn't mean giving up on queues. Emails, image processing, sitemap generation and scheduled publishing all belong in the background, especially when a slow mail server can otherwise make a signup page hang for several seconds. You just need a setup designed around the platform's limits.
The core idea: a short-lived worker started every minute
Without a process manager, you can't keep a worker alive permanently. Instead, let cron start a fresh worker every minute that processes whatever is waiting and then exits:
php artisan queue:work --queue=mail,default --stop-when-empty --max-time=55 --tries=3
--stop-when-emptyexits as soon as the queue is drained, so workers don't pile up.--max-time=55guarantees the worker exits before the next cron tick starts another one.--queue=mail,defaultprocesses emails first, so a backlog of image jobs never delays a password-reset email.
Alongside it, run the scheduler every minute:
php artisan schedule:run
The trade-off: a job may wait up to a minute before it starts. For verification emails and scheduled posts that's perfectly acceptable — just tell users "it can take up to a minute to arrive."
Trap 1: the cron command format
This one cost real debugging time. The textbook cron line looks like this:
cd /path/to/app && php artisan schedule:run >> /dev/null 2>&1
On at least one popular shared host, commands written this way simply never ran the PHP part. A test job that appended the date to a file created an empty file once and never wrote to it again, while the same command worked perfectly over SSH.
What worked was the host's dedicated "PHP" cron type with an absolute path to artisan and no shell syntax at all:
/usr/bin/php /home/USER/domains/example.com/app/artisan schedule:run
Artisan doesn't need the working directory set; it locates the application from its own path. Output was then visible in the control panel's "view output" screen, which made debugging easy.
How to verify cron is really running: don't trust the panel listing. Check the job's output, look for rows leaving the jobs table, or schedule a test post a few minutes ahead and watch whether it publishes.
Trap 2: disabled PHP functions
Shared hosts disable risky functions by default. Two of them matter to Laravel:
proc_open— required by Composer's post-install scripts and by Laravel's scheduler, which runs each scheduled command as a subprocess. If it's disabled,composer installfails atpackage:discoverand the scheduler fails on every run. Many hosts let you re-enable it from the PHP configuration panel.execandsymlink—php artisan storage:linkuses PHP'ssymlink()and falls back toexec(). With both disabled, create the link once over SSH withln -sand make your deploy script tolerate the artisan command failing.
Only re-enable what you need. Leave exec, shell_exec and system disabled if your code doesn't require them.
Trap 3: duplicate jobs that multiply
When the worker wasn't running for a while, the backlog revealed a design flaw: 147 copies of the same "refresh sitemaps" job. Every publish or edit dispatched one, and nothing deduplicated them.
On a host where a worker might only get one minute at a time, wasted jobs are expensive. Make idempotent, repeatable jobs unique:
- Implement
ShouldBeUnique(orShouldBeUniqueUntilProcessing) with a stableuniqueId()for jobs like sitemap refreshes, so a burst of twenty publishes produces one job. - Debounce them with a short delay so the burst collapses into a single run.
- For per-record jobs, such as generating a social preview image, make the unique ID include the record and a fingerprint of the inputs.
Trap 4: jobs that take too long
Shared hosting often enforces CPU or execution limits. Design every job to finish well within a minute:
- Set an explicit
$timeoutbelow your worker's--max-time. - Set an SMTP timeout in
config/mail.php, so a hung mail server can't freeze a worker. - Chunk large operations and make them resumable, storing a cursor between runs.
Don't let mail block requests
Laravel's built-in verification and password-reset notifications are sent synchronously by default. On shared hosting, that means the signup request waits for the SMTP conversation to finish.
Queue them by extending the notifications with ShouldQueue, put every mailable on a dedicated mail queue, and dispatch after the database transaction commits, so a rolled-back action never sends an email.
Monitor the worker you can't see
The scariest failure mode is silent: the worker stops, nothing errors, and emails just quietly stop arriving. Add a health check that runs from the scheduler and alerts you when:
- The oldest pending job is more than ten minutes old
- The backlog exceeds a threshold
failed_jobsisn't empty
Send that alert synchronously rather than through the queue — a dead queue can't deliver its own obituary.
Is it worth it?
For a content site, a small SaaS or an internal tool, this setup is surprisingly solid: background email, image processing, scheduled publishing and maintenance tasks, all on a few-dollar hosting plan. When you outgrow the one-minute latency or the CPU limits, moving to a VPS with Supervisor is straightforward, because your jobs were already written to be short, idempotent and unique.
The rule of thumb: on shared hosting, assume nothing runs unless you've watched it run.
Related reading: Dev–prod parity lessons · SPF, DKIM and DMARC explained · How to brief an AI coding agent safely
Frequently asked questions
Can Laravel queues run on shared hosting?
Yes. Run php artisan queue:work --stop-when-empty --max-time=55 from cron every minute, alongside schedule:run. Jobs may wait up to a minute, which is fine for emails and background tasks.
Why is my Laravel scheduler not running on shared hosting?
Common causes are a cron format the host doesn't execute (cd … && … with redirection), a wrong PHP binary path, or proc_open being disabled. Use an absolute path to artisan and check the cron output.
Why does composer install fail with a proc_open error?
Composer's post-install scripts need proc_open. Many shared hosts disable it by default but let you re-enable it in the PHP configuration panel.
How do I stop duplicate jobs piling up in the queue?
Implement ShouldBeUnique or ShouldBeUniqueUntilProcessing with a stable uniqueId for repeatable jobs such as sitemap refreshes, and debounce them with a short delay.
Related
Software
Windows 10 ESU Now Runs to October 2027: How to Check Your PC Is Enrolled
Windows 10 Extended Security Updates for home users now last until 12 October 2027. But only enrolled PCs get them. Here's how to check, how to enroll...
Software
Your Local Database Is Lying to You: Dev–Prod Parity Lessons
Tests that pass locally and fail in CI — or worse, pass everywhere and break in production — usually point to environment drift. Here are the differen...
Startups
Build vs Buy: When a Small Team Should Write Its Own CMS
Building a custom CMS is now faster than ever with AI coding tools — which makes the build-vs-buy decision easier to get wrong. A practical framework...
The stream
All storiesUpcoming Phones in India: December 2026 Launches to Wait For
Xiaomi 18 Pro, iQOO 16 and OnePlus 16R are the big flagships expected in India around December 2026, with Vivo X500 and Motorola Signature 27 already out. Here's what's confirmed so far.
Windows 10 ESU Now Runs to October 2027: How to Check Your PC Is Enrolled
Windows 10 Extended Security Updates for home users now last until 12 October 2027. But only enrolled PCs get them. Here's how to check, how to enroll for free, and when to plan your move.
GTA 6 PC Release Date: Everything Rockstar and Take-Two Have Actually Said
There is no official GTA 6 PC release date. Take-Two says any PC news will come from Rockstar. Based on GTA 5 and Red Dead Redemption 2, the realistic window is late 2027 to 2028.
ChatGPT Advanced Voice Is Being Retired on 11 December: What GPT-Live Changes
On 11 December 2026, ChatGPT retires Advanced and Standard voice and moves everyone to GPT-Live. Here's what GPT-Live does differently, what happens to custom GPTs and video, and your old chats.
ChatGPT Go Free Year Ending in India: Will You Be Charged ₹399, and How to Cancel
If you claimed free ChatGPT Go in India last year, your 12 months are ending. Here's when the ₹399 charge kicks in, how to cancel on web, Android and iPhone, and whether staying on Go is worth it.