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 inroutes/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 inroutes/console.php. You can also use the withSchedule method in bootstrap/app.php:
What you can schedule
Artisan commands
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 withtimezone():
config/app.php:
Preventing overlaps
By default, a task starts even if the previous run is still executing. UsewithoutOverlapping() 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, useonOneServer() to ensure only one server executes the task:
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. UserunInBackground() to let a long-running task execute in parallel with others:
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: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:
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: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.