Scheduled commands are the part of a Laravel app nobody looks at until a client asks why invoices stopped going out three weeks ago. Here are the failures I find most often when I take over production apps, and how to prevent each one.
1. The cron entry was never added (or got lost in a server move)
The scheduler only runs if this exists on the server:
* * * * * cd /var/www/app && php artisan schedule:run >> /dev/null 2>&1 Server migrations, new hosting panels and Docker rebuilds drop it all the time. Fix: add a heartbeat — a tiny scheduled command that pings an uptime monitor every few minutes. No ping, you get an alert.
Schedule::call(fn () => Http::get(config('services.heartbeat.url'))) ->everyFiveMinutes(); 2. Overlapping runs
A report that usually takes 2 minutes takes 70 one day, and the next run starts on top of it. Duplicate emails, double charges, locked tables.
Schedule::command('reports:daily')->daily()->withoutOverlapping(120); On multiple servers, add ->onOneServer() (requires a shared cache like Redis).
3. Timezone surprises
->dailyAt('09:00') uses app.timezone. If that's UTC and your client is in India or Dubai, emails go out at the wrong hour. Set it explicitly per task:
Schedule::command('reminders:send')->dailyAt('09:00')->timezone('Asia/Kolkata'); 4. Failures nobody sees
By default, a failing scheduled command just... fails. Wire up notifications:
Schedule::command('invoices:generate') ->daily() ->onFailure(fn () => Log::channel('slack')->error('Invoice generation failed')) ->emailOutputOnFailure('ops@example.com'); 5. Long work running inside the scheduler
If a task processes 50,000 records, don't do it inline. Let the scheduler dispatch jobs and let queue workers do the heavy lifting with retries and timeouts. The scheduler should finish in seconds.
6. Commands that assume a "current" user or tenant
In multi-tenant apps, scheduled commands have no request, no auth user and no tenant. Loop over tenants explicitly and initialise context for each one, or you'll process only the default tenant (or worse, mix data).
Quick checklist
- [ ] Cron entry verified on every server
- [ ] Heartbeat ping with alerting
- [ ]
withoutOverlapping()on anything that can run long - [ ] Explicit timezone on client-facing tasks
- [ ]
onFailurenotifications - [ ] Heavy work dispatched to queues
- [ ] Tenant context set inside the command
I'm Arun Tyagi, a freelance Laravel developer in Noida, India. Most of my retainer work is exactly this kind of quiet production hygiene — more on my Laravel maintenance and support work at aruntyagi.com.