Skip to content
  1. Extras
  2. Scheduler

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 recurring and interval fields — the next run is scheduled after a successful one, while a failure stops the cycle unless scheduler.recurring_on_failure is enabled
  • Retries on failure: the max_retries and retry_delay fields
  • 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.

SectionDescription
Installation and run setupThe package, the cron job, running over HTTP
Creating a taskTask types, fields, recurring runs and retries
Scheduling a taskQueueing a run from code
Task developmentPassing data, errors, returning a result