Active Module: Task Scheduler & Cron Daemon

Task Scheduler & Cron Daemon

Laravel's Scheduler allows you to define command execution schedules natively in code. Run commands manually to inspect their real-time outputs.

Global Last Run:

Active Scheduler Console

Artisan Command Cron Expression Interval Description Action
reports:generate 0 0 * * * Daily at Midnight Compiles transactional data, active user statistics, and DB sizes into a reports database table.
tokens:cleanup 0 * * * * Every Hour Deletes expired login tokens and active sessions that exceeded the TTL to keep database lightweight.
files:cleanup 0 0 * * * Daily at Midnight Purges unused temporary file uploads, compiled views cache, and application log blocks.
stats:generate */5 * * * * Every 5 Minutes Calculates cache hit/miss statistics and response averages for system status dashboard display.
Artisan Output Console

        

Cron Scheduling Architecture

Traditional Linux Cron Problems

In traditional setups, each scheduled script requires adding a new line to the server's crontab (e.g. `crontab -e`). This splits task versioning away from the codebase, making changes hard to manage across servers.

How Laravel Solves It

You register only **one single cron task** in Linux pointing to Laravel's schedule daemon (`* * * * * php artisan schedule:run`). Laravel then handles evaluating the intervals (`daily()`, `everyFiveMinutes()`) and executing them internally without touching server settings.

Cron Expression Syntax

*  *  *  *  *
│  │  │  │  │
│  │  │  │  └─ Day of the Week (0 - 6)
│  │  │  └───── Month (1 - 12)
│  │  └────────── Day of the Month (1 - 31)
│  └────────────── Hour (0 - 23)
└────────────────── Minute (0 - 59)
                    

cPanel / Shared Hosting Deployments

On shared hosting, simply add the scheduler command in cPanel's Cron Jobs section to run every minute. Laravel handles concurrency protection, logs, and overlaps automatically.