
Scheduler
Scheduler is a deferred task manager: it runs in the background the work that does not need to happen right away — imports and exports, sending emails, notifications.
Package: 1.9.0-pl, by Mark Hamstra and Bert Oost (modmore). Component page: modstore.pro.
Features
- Three task types: a PHP file (
sFileTask), a snippet (sSnippetTask), a processor (sProcessorTask) - Queueing a run from code for any time
strtotime()understands, with data passed into the task - Recurring tasks: the
recurringandintervalfields — the next run is scheduled after a successful one, while a failure stops the cycle unlessscheduler.recurring_on_failureis enabled - Retries on failure: the
max_retriesandretry_delayfields - Failure emails to the addresses in
scheduler.email_failure, with your own subject and chunk - History cleanup via
scheduler.delete_tasks_after— how long finished runs are kept, unlimited by default - Triggering from cron or over HTTP
- Its own section in the manager: tasks, the run queue and the execution history
- MODX 2 and MODX 3 support
A task (sTask) describes what to run and with what. A run (sTaskRun) is a single queueing of that task for a specific time, with its own data and result. One task can have any number of runs.
One package for two platforms — hence the classes without a namespace and the two ways of obtaining the scheduler service: on MODX 2 through $modx->getService(), on MODX 3 either that or the $modx->services container.
Quick links
| Section | Description |
|---|---|
| Installation and run setup | The package, the cron job, running over HTTP |
| Creating a task | Task types, fields, recurring runs and retries |
| Scheduling a task | Queueing a run from code |
| Task development | Passing data, errors, returning a result |
