agyanadda@gmail.com

Laravel Task Scheduling

Advanced Laravel 1 min read Updated Dec 2, 2026 Topic 27 of 31

The scheduler runs tasks automatically — daily reports, cleaning old records, sending reminders — with just one cron entry on the server.

Define the schedule

In Laravel 11 and later, write schedules in routes/console.php with the Schedule facade (older versions use app/Console/Kernel.php).

What you can schedule

  • An Artisan command: Schedule::command('report:send')
  • A queued job: Schedule::job(new CleanupJob)
  • A closure: Schedule::call(fn () => ...)

Frequencies

everyMinute(), everyFiveMinutes(), hourly(), daily(), dailyAt('09:00'), weekly(), monthly(), weekdays(), timezone('Asia/Kolkata').

Add one cron entry on the server

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

Cron runs schedule:run every minute, and Laravel decides which tasks are due.

Useful commands

  • php artisan schedule:list — see all tasks and their next run time
  • php artisan schedule:work — run the scheduler locally while developing

Add ->withoutOverlapping() so a slow task does not start again before the last run finishes.

Example

Example — Daily cleanup and a morning report PHP
<?php
// routes/console.php  (Laravel 11+)
use App\Models\Otp;
use Illuminate\Support\Facades\Schedule;

// Delete expired OTPs every hour
Schedule::call(function () {
    Otp::where('created_at', '<', now()->subHour())->delete();
})->hourly();

// Send a sales report at 9 AM India time, Monday to Friday
Schedule::command('report:send')
    ->weekdays()
    ->dailyAt('09:00')
    ->timezone('Asia/Kolkata')
    ->withoutOverlapping();

// Prune old login logs every Sunday
Schedule::command('model:prune')->weekly();

php artisan schedule:list shows three tasks with their next run times. On the server, the single cron line runs them all at the right times.

Test Yourself With Exercises

Exercise 1 Multiple Choice

How many cron entries does the Laravel scheduler need on the server?

Exercise 2 True / False

In Laravel 11 and later, schedules can be defined in routes/console.php.

Exercise 3 Fill in the Blank

Run php artisan schedule:___ to see all scheduled tasks.

Frequently Asked Questions

Open the Cron Jobs section in the hosting panel, choose "every minute", and enter the command with the full PHP path and project path, for example /usr/bin/php /home/user/project/artisan schedule:run. Your host's documentation shows the exact PHP path.