upsun_cron_manager
Upsun Cron Manager gives you a simple on/off switch for the scheduled cron jobs defined in your Upsun (or Platform.sh) application configuration — without editing YAML or redeploying. It reads your platform's cron definitions and stores an enabled/disabled flag for each one in Drupal's State API, so you can pause a runaway or expensive cron, freeze all scheduled tasks during a deployment or data migration, and turn them back on, all from an admin form or Drush.
Features
- Automatic cron discovery — Reads the
cronsdefined in your Upsun/Platform.sh application config. On the platform it uses thePLATFORM_APPLICATIONenvironment variable; in local development it falls back to parsing.platform.app.yamlat your repository root (path configurable via settings). - Per-cron enable/disable — An admin form lists every discovered cron with a checkbox. Toggle individual crons, or use the Enable all / Disable all buttons. State is stored per-cron in the State API and defaults to enabled.
- Orphan pruning — When a cron is removed from your platform config, its leftover state entry is cleaned up automatically on the next Drupal cron run, and on demand via the
upsun:cron-pruneDrush command. - Integer-backed state — Enabled state is stored as
1/0so it can be read directly by shell guards in your platform cron command
[ "$STATE" = "0" ] && exit 0
Plan compatibility: This module currently targets the Upsun Fixed plan, where crons are defined in your application configuration and discovered via
PLATFORM_APPLICATION / .platform.app.yaml. Support for Upsun Flex is on the roadmap.
When and why: Use this module when you run Drupal on Upsun or Platform.sh and need to control scheduled crons operationally — pausing a cron that is causing load or errors, suspending all scheduled work during a release or a long data import, or temporarily disabling background tasks in a staging branch — without a code change or redeploy.
Post-Installation
This module is a control plane: it records which crons should run, but it does not intercept the platform scheduler itself. To make the switch take effect, your platform cron command must check the stored state before doing its work.
- Install and enable the module as usual (
composer require drupal/upsun_cron_manager, then enable it). - Visit the management form at Administration → Configuration → System → Upsun Cron Manager (
/admin/config/system/upsun-cron-manager). It requires the Manage Upsun cron states permission. The form lists each cron discovered from your platform config; if it reports no crons, confirm thatPLATFORM_APPLICATIONis set (on the platform) or that.platform.app.yamlexists at your repository root (locally). - Guard each cron in your
.platform.app.yamlso it exits early when disabled. For example:
crons: drupal: spec: '*/5 * * * *' commands: start: | STATE=$(drush state:get upsun_cron_manager.enabled.drupal --default=1) [ "$STATE" = "0" ] && exit 0 drush core:cronThe state key follows the pattern
upsun_cron_manager.enabled.{cron_name}, where{cron_name}is the machine name of the cron in your platform config. - (Optional) For deployment freezes, call
saveSnapshotAndDisable()in your deploy hook andrestoreSnapshot()when finished, via theupsun_cron_manager.cron_state_managerservice.
Changes take effect on the next scheduled cron invocation — disabled crons exit immediately rather than running their workload.
Additional Requirements
- platformsh/config-reader (
^3.0) — installed automatically via Composer.