Files
scrum-poker-internal/.agents/skills/laravel-best-practices/rules/scheduling.md
T
Twyco a0467592fa
tests / ci (push) Failing after 1m54s
CI/CD / test_and_check_app (push) Failing after 2m44s
CI/CD / Publish immutable image (push) Skipped
lint & install nightwatch
2026-08-24 21:17:12 +02: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');
    });