Files
fivem-mcp/.agents/skills/laravel-best-practices/rules/scheduling.md
T
Adrian Mejias 0bedeed913 Add Prodigy event and export documentation views, enhance tests
- Created new Blade views for displaying Prodigy events and exports, including detailed references.
- Implemented tests for Prodigy client and server event/export reference tools to ensure correct functionality.
- Updated Pest test configuration for improved test case handling.
2026-03-28 15:07:29 -05:00

1.3 KiB

Task Scheduling Best Practices

Use withoutOverlapping() on Variable-Duration Tasks

Without it, a long-running task spawns a second instance on the next tick, causing double-processing or resource exhaustion.

Use onOneServer() on Multi-Server Deployments

Without it, every server runs the same task simultaneously. Requires a shared cache driver (Redis, database, Memcached).

Use runInBackground() for Concurrent Long Tasks

By default, tasks at the same tick run sequentially. A slow first task delays all subsequent ones. runInBackground() runs them as separate processes.

Use environments() to Restrict Tasks

Prevent accidental execution of production-only tasks (billing, reporting) on staging.

Schedule::command('billing:charge')->monthly()->environments(['production']);

Use takeUntilTimeout() for Time-Bounded Processing

A task running every 15 minutes that processes an unbounded cursor can overlap with the next run. Bound execution time.

Use Schedule Groups for Shared Configuration

Avoid repeating ->onOneServer()->timezone('America/New_York') across many tasks.

Schedule::daily()
    ->onOneServer()
    ->timezone('America/New_York')
    ->group(function () {
        Schedule::command('emails:send --force');
        Schedule::command('emails:prune');
    });