Welcome to HowToShipIt — practical how-to guides for developers: code, AI tools, and servers, explained step by step.

Laravel Scheduler: The Complete Guide to Scheduled Tasks (2026)

Every Laravel app eventually needs something to happen on a clock: nightly report emails, expired-token cleanup, a weekly digest, an hourly sync with a third-party API. The raw way to do it is a crontab full of one-off entries, each pointing at a different Artisan command. The Laravel scheduler replaces all of that with one cron entry and a schedule defined in PHP, version-controlled next to the rest of your code. This guide covers the scheduler the way you will actually use it in production: setup, the four ways to schedule work, overlap and multi-server guards, sub-minute tasks, and — the part most tutorials skip — how to know when a task silently stops running. Verified 17 November 2026 against the official Laravel 13.x scheduling documentation and the Laravel 13.42 release notes; all code samples target Laravel 13.x.

How the Laravel Scheduler Actually Works

The scheduler is not a daemon and it does not run on its own. It is a thin layer on top of the system cron you already have. You add exactly one cron entry to your server:

* * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1

Every minute, cron wakes Laravel up. The schedule:run command evaluates every task you defined against the server’s current time and runs whatever is due. That is the whole value proposition: your schedule lives in code, it is reviewed like any other code, and adding a task never means SSH-ing into a server to edit a crontab.

You define tasks in routes/console.php using the Schedule facade:

use Illuminate\Support\Facades\Schedule;

Schedule::command('reports:send')->dailyAt('06:00');
Schedule::command('tokens:prune')->daily();
Schedule::job(new SyncInvoices)->hourly();

If you would rather keep routes/console.php for command definitions only, you can define the schedule in bootstrap/app.php with ->withSchedule(), which receives an instance of the scheduler. Either way, one command tells you what Laravel thinks is scheduled and when each task runs next:

php artisan schedule:list

Run that before you deploy anything. If a task is missing from the list, it is not registered — and no amount of cron debugging will help.

Setting Up the Laravel Scheduler in 5 Minutes

1. Define a task

Pick one real recurring job your app already needs — a cleanup command is the classic first task — and register it in routes/console.php:

use Illuminate\Support\Facades\Schedule;

Schedule::command('tokens:prune')->daily();
Schedule::command('reports:send')->dailyAt('06:00');

2. Test it locally with schedule:work

Do not add a cron entry to your development machine. Laravel ships schedule:work, which runs in the foreground and invokes the scheduler every minute until you stop it:

php artisan schedule:work

It holds a process open, so it has no place in production — use it to confirm your task fires, then move on.

3. Add the one cron entry on the server

On your VPS, open the crontab for the user that owns the application files and add the single entry shown above. Two details trip people up. First, cron runs with a bare PATH, so php may resolve to the wrong binary — or none at all — after a server update. Use the full path to the PHP binary (for example /usr/bin/php8.3) and cd into the project directory first. Second, the crontab must belong to the right user: a root crontab running your app’s scheduler creates cache and log files owned by root, which your app user then cannot write to.

The 4 Ways to Schedule Work in Laravel

Artisan commands

The most common case. Schedule a command by name, or by class with arguments:

Schedule::command('emails:send Taylor --force')->daily();
Schedule::command(SendEmailsCommand::class, ['Taylor', '--force'])->daily();

Queued jobs

Use job() when the work is heavy or should survive a deploy. The scheduler only dispatches the job; a queue worker does the work. You can pass the queue name and connection as the second and third arguments:

Schedule::job(new Heartbeat)->everyFiveMinutes();
Schedule::job(new Heartbeat, 'heartbeats', 'sqs')->everyFiveMinutes();

This is the right shape for anything that takes more than a few seconds. If you have not set up workers yet, see our guide to running Laravel queue workers in production with Supervisor.

Closures and invokable classes

For small inline work, call() takes a closure or an invokable object:

Schedule::call(function () {
    DB::table('recent_users')->delete();
})->daily();

Schedule::call(new DeleteRecentUsers)->daily();

Keep closures short. Once one grows past a few lines, move it into a proper Artisan command or job, where it can be tested and logged.

Shell commands

exec() runs an operating-system command — useful for scripts that live outside Laravel:

Schedule::exec('node /home/forge/script.js')->daily();

Frequencies, Constraints, and the Timezone Trap

The scheduler’s frequency methods read like plain English: everyMinute(), everyFiveMinutes(), hourly(), hourlyAt(17), daily(), dailyAt('13:00'), twiceDaily(1, 13), weekly(), monthly(), quarterly(), yearly(), and cron('* * * * *') when you need a raw expression. Newer additions include daysOfMonth([1, 10, 20]) for billing-cycle style schedules.

Constraints narrow a schedule further:

Schedule::command('emails:send')
    ->weekdays()
    ->hourly()
    ->between('8:00', '17:00');

Schedule::command('emails:send')
    ->daily()
    ->when(fn () => config('services.reports.enabled'));

Schedule::command('emails:send')
    ->daily()
    ->skip(fn () => app()->isDownForMaintenance());

when() runs the task only when its closure returns true; skip() is the inverse. environments(['staging', 'production']) limits a task to specific environments, which is how you stop a staging server from sending your customers real emails at 6am.

Timezones deserve a warning of their own. You can set a per-task timezone with ->timezone('America/New_York'), or a global default with the schedule_timezone config option. But some timezones observe daylight saving time, and when the clocks change, a task scheduled at 02:30 may run twice or not at all. The official documentation recommends avoiding timezone scheduling when possible. The safest default is to keep your server and your schedule in UTC and convert only at the edges — for example, when a task’s business meaning is tied to a local time, like a 9am report for a specific office.

Stopping Tasks from Colliding: Overlaps, One Server, Background Runs

Three methods exist because three different collisions exist. Do not confuse them.

withoutOverlapping(): the same task vs itself

By default, a scheduled task runs even if the previous instance is still running. A report that normally takes 40 seconds but occasionally takes 90 will stack up on itself if it runs every minute. withoutOverlapping() prevents that:

Schedule::command('emails:send')->withoutOverlapping();

Two details matter. First, the lock is held in your application’s cache, so this feature requires the database, memcached, dynamodb, or redis cache driver — the file and array drivers will not work, and all servers must share the same central cache. Second, the lock expires after 24 hours by default. If a task crashes while holding the lock, the next run is skipped for up to a day. Pass an explicit expiry that matches the task’s worst-case runtime — withoutOverlapping(10) expires the lock after 10 minutes — and remember php artisan schedule:clear-cache exists to clear a stuck lock by hand.

onOneServer(): the same task vs your other servers

withoutOverlapping() stops one task colliding with itself. It does nothing about three app servers each running the same Friday-night report. onOneServer() does: the first server to obtain an atomic lock runs the task, and the others skip it.

Schedule::command('report:generate')
    ->fridays()
    ->at('17:00')
    ->onOneServer();

If every task should run on one server, call Schedule::alwaysOnOneServer() in your AppServiceProvider‘s boot() method. Two gotchas: unnamed closures are excluded and keep running on every server, and when you schedule the same job with different parameters you must give each definition a unique ->name(), or the lock names collide and only one permutation ever runs.

runInBackground(): the long task vs everything after it

By default, tasks scheduled at the same time run sequentially, in definition order. One slow task delays everything behind it. runInBackground() lets tasks run simultaneously:

Schedule::command('analytics:report')
    ->daily()
    ->runInBackground();

It only works with command and exec. For queued jobs, dispatching the job and letting the worker handle it is usually the better choice anyway, because a queued job can be retried.

Sub-Minute Tasks and the Deploy Gotcha

Cron can only fire once a minute, but Laravel’s scheduler supports sub-minute frequencies: everySecond(), everyFiveSeconds(), everyTenSeconds(), everyThirtySeconds(), and so on. When sub-minute tasks are defined, schedule:run keeps running until the end of the current minute instead of exiting immediately, invoking each sub-minute task on its interval.

Schedule::job(new DeleteRecentUsers)->everyTenSeconds();
Schedule::command('users:delete')->everyTenSeconds()->runInBackground();

The official guidance is clear: sub-minute tasks should dispatch queued jobs or background commands, because a sub-minute task that runs long delays every later sub-minute task in the same minute. And there is a deploy gotcha most teams discover the hard way: a schedule:run invocation that is already running keeps using your application’s previously deployed code until the current minute ends. Add php artisan schedule:interrupt to your deployment script, after the deploy finishes, to interrupt in-progress invocations so the next minute picks up the new code.

Maintenance Mode, Pausing, and Groups

Scheduled tasks do not run while the application is in maintenance mode — Laravel assumes you do not want background work interfering with whatever you are fixing. A task that must run anyway gets evenInMaintenanceMode():

Schedule::command('emails:send')->evenInMaintenanceMode();

For a temporary stop without a deploy, php artisan schedule:pause halts all scheduled task processing, and php artisan schedule:continue resumes it. A task that should keep running while paused gets evenWhenPaused(). This is the safe way to freeze the schedule during an incident: one command, no code change, no deploy.

When several tasks share the same configuration, group them instead of repeating the same chain on every line:

Schedule::daily()
    ->onOneServer()
    ->timezone('America/New_York')
    ->group(function () {
        Schedule::command('emails:send --force');
        Schedule::command('emails:prune');
    });

Knowing When a Task Fails

A task that never runs produces no error, no log line, and no alert. You need three layers, and they catch different failures.

Layer 1: hooks on the task itself

before() and after() run around the task. onSuccess() and onFailure() fire based on the exit code — a failure means the Artisan or system command exited non-zero. You can read the task’s output inside a hook by type-hinting Illuminate\Support\Stringable:

Schedule::command('report:generate')
    ->daily()
    ->onFailure(function (Stringable $output) {
        Log::error('Nightly report failed', ['output' => (string) $output]);
    });

Output methods — sendOutputTo(), appendOutputTo(), emailOutputTo(), and emailOutputOnFailure() — are exclusive to command and exec tasks. emailOutputOnFailure() is the one to reach for first: it only emails you when something went wrong.

Layer 2: pings to an external monitor

Hooks only fire when the task runs. If cron itself dies, nothing fires — which is exactly the failure you most need to catch. The scheduler’s ping methods solve this by notifying an external service before and after a task:

Schedule::command('report:generate')
    ->daily()
    ->pingBefore($url)
    ->thenPing($url);

Schedule::command('report:generate')
    ->daily()
    ->pingOnSuccess($successUrl)
    ->pingOnFailure($failureUrl);

Point these at a dead-man’s-switch service such as Healthchecks.io, whose free tier covers 20 monitors — enough for most small applications. The service expects a ping on schedule and alerts you when one does not arrive, which catches the dead-cron case that no in-app hook can see. Conditional variants (pingBeforeIf, thenPingIf, pingOnSuccessIf, pingOnFailureIf) let you ping only when a condition holds.

Layer 3: scheduler events

Laravel dispatches events through the whole scheduling lifecycle: ScheduledTaskStarting, ScheduledTaskFinished, ScheduledBackgroundTaskFinished, ScheduledTaskSkipped, and ScheduledTaskFailed.

Laravel 13.42, released 10 November 2026, made the skip event genuinely useful: ScheduledTaskSkipped now carries a reason property, a ScheduledTaskSkipReason enum with three cases — ConditionNotMet, Paused, and RanOnAnotherServer:

use Illuminate\Console\Events\ScheduledTaskSkipped;

Event::listen(function (ScheduledTaskSkipped $event) {
    Log::info('Scheduled task skipped', [
        'task' => $event->task->getSummaryForDisplay(),
        'reason' => $event->reason?->value,
    ]);
});

The same release improved schedule:list --json so it reports each task’s own cron expression and timezone instead of converting everything to the application timezone — a small change that stops stored schedule snapshots from drifting by an hour after a DST change. For the full 13.42 release, see our Laravel 13.42 guide.

7 Mistakes That Break the Laravel Scheduler in Production

1. Redirecting everything to /dev/null and never verifying cron fires

The standard cron entry discards all output. That is fine — until the cron daemon stops, the PHP binary moves, or the crontab belongs to the wrong user. Then your tasks silently stop and nothing tells you. Log the scheduler’s output to a file you check, and put a heartbeat ping on at least one frequent task so a dead cron daemon pages you.

2. Trusting the default 24-hour overlap lock

withoutOverlapping() with no argument holds its lock for 24 hours. A task that crashes while holding it will not run again until the lock expires. Pass an explicit expiry close to the task’s worst-case runtime, and know that schedule:clear-cache clears a stuck lock.

3. Using onOneServer() with the wrong cache driver

Single-server locks live in the cache. With the file or array driver, each server has its own cache, so the lock never coordinates anything and the task runs on every server anyway. Use database, memcached, dynamodb, or redis, shared across all servers.

4. Running long work synchronously in the scheduler

A task that takes three minutes blocks every task scheduled behind it. Dispatch a queued job or use runInBackground(). The scheduler’s job is to decide when work happens, not to do the work itself.

5. Scheduling by local time around daylight saving changes

A daily task at 02:30 in a DST timezone can run twice or skip a day when the clocks change. Keep the schedule in UTC unless a task’s business meaning genuinely depends on a local time.

6. Having no failure signal at all

Laravel logs a failed scheduled task and moves on. No retry, no alert, no dashboard entry. At minimum, add emailOutputOnFailure() or a pingOnFailure() URL to every task that matters.

7. Deploying without schedule:interrupt

If you use sub-minute tasks, a schedule:run invocation from before your deploy keeps running the old code until the minute ends. Add schedule:interrupt to your deploy script after the new code is in place.

A Production-Ready routes/console.php

Pulling it together, here is what a small production schedule looks like — grouped, guarded, and observable:

use Illuminate\Support\Facades\Schedule;
use Illuminate\Support\Stringable;

Schedule::daily()
    ->onOneServer()
    ->environments(['production'])
    ->group(function () {
        Schedule::command('reports:send')
            ->dailyAt('06:00')
            ->withoutOverlapping(30)
            ->onFailure(fn (Stringable $output) =>
                Log::error('Morning report failed', ['output' => (string) $output])
            )
            ->pingOnFailure(config('services.healthchecks.reports'));

        Schedule::command('tokens:prune')
            ->daily()
            ->withoutOverlapping(10);

        Schedule::command('invoices:sync')
            ->hourly()
            ->runInBackground();
    });

Schedule::job(new Heartbeat)->everyFiveMinutes();
Schedule::command('backups:run')->dailyAt('02:00')->evenInMaintenanceMode();

Every task in the group runs on one server, in production only. The report has an overlap guard with a 30-minute expiry, a failure hook that logs the output, and a failure ping to an external monitor. The heartbeat job proves the scheduler itself is alive every five minutes. The backup runs even in maintenance mode, because a deploy should never be the reason you lose a night’s backup.

Start small: one task, one cron entry, one heartbeat. Add the guards as the schedule grows. Most of the ways the scheduler fails in production are not in the scheduler at all — they are in the cron entry, the cache driver, or the missing alert. Fix those three, and the schedule will quietly do its job for years.

Further Reading & References

Related on HowToShipIt: How to Run Laravel Queue Workers in Production with Supervisor · Laravel 13.42: Typed UUID Input, Failed-Migration Alerts, and the Security Fix · Laravel Notifications: One Class, Every Channel · Laravel Pulse: Set Up Your Free Production Health Dashboard

Leave a Comment