Scheduler
Scheduler gives website editors the ability to schedule content to be published and unpublished at specified dates and times in the future.
scheduler
Install
composer require 'drupal/scheduler:8.x-1.6'
Overview
Scheduler is a powerful module that provides automatic publishing and unpublishing of entities at specified future dates and times. It supports multiple entity types through a flexible plugin architecture including Node content, Media entities, Commerce Products, and Taxonomy Terms.
The module provides hooks and events for third-party modules to interact with the scheduling process during content editing and during cron-based publishing and unpublishing operations. Scheduler integrates seamlessly with Drupal's cron system but also provides a lightweight cron option for more granular scheduling control without running the full Drupal cron.
Scheduler supports multilingual content with per-translation scheduling dates, revision creation for both publishing and unpublishing actions, and flexible handling of past dates including immediate publishing or scheduled processing on the next cron run.
Features
- Schedule content for automatic publishing at a specified future date and time
- Schedule content for automatic unpublishing at a specified future date and time
- Support for Node, Media, Commerce Product, and Taxonomy Term entities via plugin architecture
- Lightweight cron functionality for more frequent scheduling without running full Drupal cron
- Per-entity-type configuration with granular control over publishing and unpublishing options
- Option to create new revisions when publishing or unpublishing scheduled content
- Flexible handling of past dates - error display, immediate publishing, or schedule for next cron
- Change entity creation time to match scheduled publish time
- Display scheduling fields as vertical tabs or separate fieldset
- Configurable date-only input with default time settings
- Hide seconds option for cleaner time input interface
- Tokens for publish_on and unpublish_on dates
- SEO-friendly X-Robots-Tag header for scheduled unpublishing dates
- Integration with Devel Generate for test content with scheduling dates
- Migration support for Drupal 7 Scheduler data
- Multilingual support with per-translation scheduling
Use Cases
Time-sensitive Press Releases
Schedule press releases to be published at a specific date and time when an embargo lifts. The content can be prepared in advance and will automatically go live at the exact moment specified without manual intervention.
Limited-time Promotions
Set up promotional content like sales announcements or special offers with both publish and unpublish dates. The promotion automatically appears when it starts and disappears when it ends.
Content Calendars
Marketing teams can prepare content weeks in advance with scheduled publication dates, enabling better planning and consistent publishing schedules without requiring someone to manually publish each piece.
Global Content Releases
Schedule content to publish at midnight in a specific timezone for coordinated global releases, ensuring content goes live at the intended local time for the target audience.
Seasonal Content
Automatically publish and unpublish seasonal or holiday-related content. Christmas content can be scheduled to appear December 1st and disappear January 2nd without manual management.
Commerce Flash Sales
Schedule Commerce products to be published for limited-time flash sales. Products can automatically become visible at sale start and hidden when the sale ends.
Workflow with Rules
Combine with the Rules module to create complex workflows. For example, send notification emails when content is scheduled, or automatically add tags to scheduled content.
Multilingual Content Coordination
Schedule different language translations to publish at different times, allowing for staggered regional releases or coordinated simultaneous global launches.
Tips
- Use the lightweight cron for more frequent scheduling checks without the overhead of full Drupal cron. Set up a separate crontab entry to call /scheduler/cron/{access-key}.
- The system status report at /admin/reports/status includes a Scheduler Timecheck section showing server time, site time, and user time for debugging timezone issues.
- When using Content Moderation, install the Scheduler Content Moderation Integration module for proper workflow state handling.
- Enable logging during initial setup to verify scheduling is working correctly, then disable it to reduce database log entries.
- Tokens [node:scheduler-publish] and [node:scheduler-unpublish] can be used in pathauto patterns to include scheduling dates in URLs.
- The X-Robots-Tag header is automatically added for content with unpublish dates, helping search engines know when content will become unavailable.
- For testing, use Devel Generate with the Scheduler integration to create content with random scheduling dates.
Technical Details
Admin Pages 3
/admin/config/content/scheduler
Configure global settings for scheduled publishing and unpublishing that apply to all entity types. This page provides quick links to configure individual content types, media types, product types, and vocabularies.
/admin/config/content/scheduler/cron
Configure and test the lightweight cron functionality for running Scheduler independently from the full Drupal cron. Useful for sites that need more frequent scheduling checks.
/admin/structure/types/manage/{content_type}
Per-content-type configuration for scheduling options. Access via Structure > Content types > Edit for each type.
Permissions 9
Hooks 21
hook_scheduler_list
Add entity IDs to the list being processed during cron. Allows modules to add entities for scheduled publishing or unpublishing.
hook_scheduler_TYPE_list
Entity-type specific version of hook_scheduler_list. Called only for the specified entity type.
hook_scheduler_list_alter
Manipulate the list of entity IDs being processed during cron. Can add or remove IDs from the list.
hook_scheduler_TYPE_list_alter
Entity-type specific version of hook_scheduler_list_alter.
hook_scheduler_publishing_allowed
Deny publishing of an entity. Return FALSE to prevent publication. The entity will be retried on subsequent cron runs.
hook_scheduler_TYPE_publishing_allowed
Entity-type specific version of hook_scheduler_publishing_allowed.
hook_scheduler_unpublishing_allowed
Deny unpublishing of an entity. Return FALSE to prevent unpublication.
hook_scheduler_TYPE_unpublishing_allowed
Entity-type specific version of hook_scheduler_unpublishing_allowed.
hook_scheduler_hide_publish_date
Hide the Publish On field on entity edit forms. Return TRUE to hide the field.
hook_scheduler_TYPE_hide_publish_date
Entity-type specific version of hook_scheduler_hide_publish_date.
hook_scheduler_hide_unpublish_date
Hide the Unpublish On field on entity edit forms. Return TRUE to hide the field.
hook_scheduler_TYPE_hide_unpublish_date
Entity-type specific version of hook_scheduler_hide_unpublish_date.
hook_scheduler_publish_process
Process the publish action for an entity. Allows custom publishing logic. Return 1 if handled, 0 for default processing, -1 on error.
hook_scheduler_TYPE_publish_process
Entity-type specific version of hook_scheduler_publish_process.
hook_scheduler_unpublish_process
Process the unpublish action for an entity. Allows custom unpublishing logic. Return 1 if handled, 0 for default processing, -1 on error.
hook_scheduler_TYPE_unpublish_process
Entity-type specific version of hook_scheduler_unpublish_process.
hook_query_scheduler_alter
Alter the database query for selecting entities to process. Standard Drupal query alter hook.
hook_query_scheduler_publish_alter
Alter the query for selecting entities to publish.
hook_query_scheduler_unpublish_alter
Alter the query for selecting entities to unpublish.
hook_query_scheduler_TYPE_publish_alter
Entity-type specific query alter for publishing.
hook_query_scheduler_TYPE_unpublish_alter
Entity-type specific query alter for unpublishing.
Drush Commands 3
drush scheduler:cron
Run Scheduler's lightweight cron process. Only processes scheduled publishing and unpublishing, not full Drupal cron.
drush scheduler:entity-update
Add Scheduler database fields (publish_on, unpublish_on) for entities covered by plugins. Run after enabling modules that provide new entity types.
drush scheduler:entity-revert
Remove Scheduler fields and third-party-settings from entity types that are no longer supported by plugins. Use when a plugin is removed after being used.
Troubleshooting 7
Ensure Drupal cron is running. Check that the content type has scheduled publishing enabled. Verify the user has the 'schedule publishing of nodes' permission. Check the dblog for any error messages from Scheduler.
Verify the access key in the URL matches the key configured at /admin/config/content/scheduler/cron. Regenerate the key if needed.
Check that the entity type has scheduling enabled in its settings. Verify the user has scheduling permissions. Check the Form Display settings to ensure fields are not hidden.
Edit the content type settings and change 'Action for publication dates in the past' from 'Display an error message' to 'Publish immediately after saving'.
Ensure the field widget is set to 'Timestamp (no default)' rather than the core 'Datetime Timestamp' widget. This can be configured in the Form Display settings.
Scheduler provides $publish_on and $unpublish_on variables in preprocess. For node and media templates, these are automatically available. For other entity types, the variables may need to be accessed differently.
Ensure the publish_on and unpublish_on fields have matching translation settings with the status field. Check Content language settings at /admin/config/regional/content-language.
Security Notes 4
- The 'administer scheduler' permission allows changing global settings and should only be granted to trusted administrators.
- The lightweight cron access key provides basic security but should be kept confidential. Regenerate it if compromised.
- Users with scheduling permissions can effectively control when content becomes visible, which may have content governance implications.
- Scheduled content is saved as unpublished until the publish date, so standard content access controls apply.