Skip to main content

What is task scheduling?

Traditionally, you would create a cron entry on your server for every recurring task. This approach scatters your schedule definitions outside version control and requires SSH access every time you want to change them. Laravel’s scheduler lets you define all scheduled tasks in code, using an expressive API. You only need one cron entry on your server, and your entire schedule lives alongside your application. Define your scheduled tasks in routes/console.php:
Run php artisan schedule:list to see all defined tasks and when they will next execute.

How the scheduler works

Defining schedules

Write schedules in routes/console.php. You can also use the withSchedule method in bootstrap/app.php:

What you can schedule

Artisan commands

You can also chain a schedule method directly onto a closure command:

Queued jobs

Shell commands

Closures

Frequency options

Common frequency methods

Custom cron expressions

Combining frequency and day constraints

Day constraints

Timezones

Set a per-task timezone with timezone():
Set a default timezone for all tasks in config/app.php:
If a timezone observes daylight saving time, a task scheduled during the transition hour may run twice (when clocks fall back) or be skipped entirely (when clocks spring forward). UTC avoids these issues and is the safest choice for scheduled tasks.

Preventing overlaps

By default, a task starts even if the previous run is still executing. Use withoutOverlapping() to ensure only one instance runs at a time:
withoutOverlapping() uses the application cache to manage locks. If a task gets stuck, clear the lock with php artisan schedule:clear-cache.

Conditions and constraints

Running on one server

When your scheduler runs on multiple servers, use onOneServer() to ensure only one server executes the task:
This feature requires your default cache driver to be database, memcached, dynamodb, or redis, and all servers must share the same cache server.

How onOneServer() works

Grouping tasks

Apply shared configuration to multiple tasks at once:

Background execution

Tasks scheduled at the same time run sequentially by default. Use runInBackground() to let a long-running task execute in parallel with others:
runInBackground() works only with command() and exec() tasks.

Maintenance mode

Scheduled tasks are skipped when the application is in maintenance mode. To force a task to run even then:

Maintenance mode handling flow

Pausing the scheduler

Pause and resume the entire scheduler without touching code:
To keep a specific task running while the scheduler is paused:

Output handling

Task hooks

Deploying to a server

1

Add one cron entry

Add a single line to the server’s crontab. Laravel’s scheduler dispatches all your tasks from there.
Edit the crontab with crontab -e.
2

Verify your schedule

List all defined tasks and their next execution times:
Laravel Cloud manages scheduled tasks for you without any cron configuration.

Local development

Run the scheduler continuously in the foreground during development—no cron needed:

Sub-minute scheduling

Normal cron only goes down to one-minute intervals. Laravel supports per-second scheduling:
When sub-minute tasks are defined, schedule:run stays alive for the entire minute and fires them at the right moments. To interrupt an in-progress schedule:run during a deployment:

Common commands reference

Artisan console

Build custom Artisan commands to use in your scheduled tasks.
Last modified on April 8, 2026