In traditional server administration, automating repetitive tasks (daily database backups, hourly currency exchange updates, weekly newsletter dispatching) required logging into your Linux terminal via SSH and configuring multiple confusing crontab entries. In Laravel, you configure a single master cron entry on your server, and manage all schedules directly in clean, version-controlled PHP code.
On your production Linux server, execute crontab -e and add this single line:
* * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1
This cron entry evaluates every single minute. It invokes Laravel's scheduler, which inspects your scheduled tasks and executes whichever jobs are due!
In Laravel 11, define scheduled tasks in routes/console.php using the Schedule facade:
use Illuminate\Support\Facades\Schedule;
// 1. Schedule a custom Artisan command to run every Monday at 8:00 AM
Schedule::command('report:weekly-digest')
->weeklyOn(1, '08:00')
->withoutOverlapping() // Uses Redis cache lock to prevent concurrent overlaps!
->emailOutputOnFailure('devops@veewom.com');
// 2. Schedule a Queued Job to run every 15 minutes during business hours
Schedule::job(new \App\Jobs\SyncStockInventory)
->everyFifteenMinutes()
->weekdays()
->between('09:00', '18:00');
// 3. Schedule a simple PHP closure every night at midnight
Schedule::call(function () {
\App\Models\UserCart::where('updated_at', '<', now()->subDays(30))->delete();
})->dailyAt('00:00');
| Frequency Method | Execution Timing |
|---|---|
->everyMinute() |
Runs every 60 seconds |
->hourly() / ->hourlyAt(15) |
Runs once an hour (or at 15 minutes past the hour) |
->daily() / ->dailyAt('13:00') |
Runs once a day at 1:00 PM |
->weekly() / ->monthly() |
Runs once a week or once a month |
->onOneServer() |
Executes on only ONE server across a multi-server cluster |
Broaden your backend architecture, REST API design, and enterprise production engineering expertise:
Write custom Artisan commands to schedule inside routes/console.php.
Dispatch queued jobs from the scheduler to maintain instant execution intervals.
Prevent scheduled tasks from overlapping using Redis atomic cache locks.
Configure * * * * * php /path/to/artisan schedule:run >> /dev/null 2>&1.