laravel-scheduling
Step 6 of the pipeline (WORKFLOW.md). A scheduled task runs unattended, on a clock, possibly on several
servers at once. Extends skills/laravel-conventions §7 (commands, schedule timezone) and §8 (jobs).
Special status. New block, 🟡: never run on real work in house. Checked on 2026-10-20 against the
framework's scheduling documentation (12.x) and the Laravel Boost rule file; re-read the page of the installed
version before relying on a method.
When
Schedule:: definitions (or the console routes file), a new command meant to run on a clock, or a report
that a task ran twice, overlapped, or never ran.
Steps
- Overlap is opt-in protection.
withoutOverlapping() stops a second run while the previous holds the
lock. Its argument is the lock's expiry in minutes, not a task timeout; the default is 24 hours, a stale lock
is cleared with the schedule cache-clear command, and an expiry shorter than the real duration allows the
overlap it was meant to prevent. The task must still survive being retried and partly done.
- Several scheduler nodes mean
onOneServer(). Every node must use the same central default cache
store, and the documentation lists the database, memcached, dynamodb and redis drivers as the ones
that work. A scheduled closure needs a name before onOneServer(), especially
the same closure scheduled with different parameters, or the tasks share a lock identity.
runInBackground() for long independent commands, since due tasks otherwise run one after another and
a slow one delays the rest. It exists only for command() and exec() tasks, not closures, and a
background task needs its own logging and failure monitoring because the scheduler no longer waits on it.
environments([...]) is an operational guard, not authorisation. It keeps a billing task out of
staging; it protects nothing from a user.
- Shared constraints go in a group (frequency, server, timezone), only when tasks genuinely share them.
- The scheduler cannot stop a task at a deadline. Bound the work inside the command or job: finite
chunks, a deadline checked in the loop, or queue jobs with their own timeouts. Hard termination needs
process-level control.
- A task prints what it did. An unattended command gives the operator a line per item and a summary
(
skills/laravel-conventions §7), so a crash at 03:00 names the item.
- Test the command, not the clock. Run the command directly in a test; keep the schedule line a one-line
registration so there is nothing in it to test.
Output / checkpoint
Each new scheduled task states its overlap policy, its single-server behaviour if the app runs on more than one
node, and how its work is bounded. Checked at review (8).
Guardrails
No comments in the code produced. New and changed code only (skills/code-baseline §0). A stale-lock
cleanup is an operator action, never part of the task.
Origin
Rewritten from the scheduling rule file of Laravel Boost (laravel/boost, MIT, LICENSE read 2026-10-20) and
checked the same day against the framework's task scheduling documentation, 12.x (facts only, our words):
Preventing Task Overlaps (argument in minutes, 24-hour default, schedule:clear-cache), Running Tasks on One
Server (drivers, atomic lock, name() for closures), Background Tasks (command and exec only), Environment
Constraints, Schedule Groups, Task Output. The statements that the scheduler cannot enforce a deadline and that
background tasks need their own monitoring come from the rule file only; the documentation does not say them.
Steps 7 and 8 are own guidance. Mechanisms only, rewritten in our words.
Independent verification 2026-10-21: 9 checked, 9 matched, 0 corrected, 0 unverified.
1---2name: laravel-scheduling3description: "Use when adding or reviewing a scheduled task in a Laravel app: overlap, running on one server, background runs, environment restrictions, shared constraints and bounding the work inside the task."4metadata:5 source: https://skillmd.com/skills/techmefr/laravel-scheduling6---78# laravel-scheduling910Step 6 of the pipeline (`WORKFLOW.md`). A scheduled task runs unattended, on a clock, possibly on several11servers at once. Extends `skills/laravel-conventions` §7 (commands, schedule timezone) and §8 (jobs).1213**Special status.** New block, 🟡: never run on real work in house. Checked on 2026-10-20 against the14framework's scheduling documentation (12.x) and the Laravel Boost rule file; re-read the page of the installed15version before relying on a method.1617## When18`Schedule::` definitions (or the console routes file), a new command meant to run on a clock, or a report19that a task ran twice, overlapped, or never ran.2021## Steps221. **Overlap is opt-in protection.** `withoutOverlapping()` stops a second run while the previous holds the23 lock. Its argument is the lock's expiry in minutes, not a task timeout; the default is 24 hours, a stale lock24 is cleared with the schedule cache-clear command, and an expiry shorter than the real duration allows the25 overlap it was meant to prevent. The task must still survive being retried and partly done.262. **Several scheduler nodes mean `onOneServer()`.** Every node must use the same central default cache27 store, and the documentation lists the `database`, `memcached`, `dynamodb` and `redis` drivers as the ones28 that work. A scheduled closure needs a name before `onOneServer()`, especially29 the same closure scheduled with different parameters, or the tasks share a lock identity.303. **`runInBackground()` for long independent commands**, since due tasks otherwise run one after another and31 a slow one delays the rest. It exists only for `command()` and `exec()` tasks, not closures, and a32 background task needs its own logging and failure monitoring because the scheduler no longer waits on it.334. **`environments([...])` is an operational guard, not authorisation.** It keeps a billing task out of34 staging; it protects nothing from a user.355. **Shared constraints go in a group** (frequency, server, timezone), only when tasks genuinely share them.366. **The scheduler cannot stop a task at a deadline.** Bound the work inside the command or job: finite37 chunks, a deadline checked in the loop, or queue jobs with their own timeouts. Hard termination needs38 process-level control.397. **A task prints what it did.** An unattended command gives the operator a line per item and a summary40 (`skills/laravel-conventions` §7), so a crash at 03:00 names the item.418. **Test the command, not the clock.** Run the command directly in a test; keep the schedule line a one-line42 registration so there is nothing in it to test.4344## Output / checkpoint45Each new scheduled task states its overlap policy, its single-server behaviour if the app runs on more than one46node, and how its work is bounded. Checked at `review` (8).4748## Guardrails49No comments in the code produced. New and changed code only (`skills/code-baseline` §0). A stale-lock50cleanup is an operator action, never part of the task.5152## Origin53Rewritten from the `scheduling` rule file of Laravel Boost (`laravel/boost`, MIT, LICENSE read 2026-10-20) and54checked the same day against the framework's task scheduling documentation, 12.x (facts only, our words):55Preventing Task Overlaps (argument in minutes, 24-hour default, `schedule:clear-cache`), Running Tasks on One56Server (drivers, atomic lock, `name()` for closures), Background Tasks (`command` and `exec` only), Environment57Constraints, Schedule Groups, Task Output. The statements that the scheduler cannot enforce a deadline and that58background tasks need their own monitoring come from the rule file only; the documentation does not say them.59Steps 7 and 8 are own guidance. Mechanisms only, rewritten in our words.6061Independent verification 2026-10-21: 9 checked, 9 matched, 0 corrected, 0 unverified.