Drupal Odyssey is supported by it's readers. When you purchase products or services using the links on this site, we may earn a small commission at no additional cost to you. Learn more
The internet today is a living, breathing thing. For website owners, this means constantly having new and engaging content regularly. But there are times when publishing your content exactly when your users expect it is inconvenient at best. Think about holidays, busy weekends, or when your dedicated content manager is finally enjoying a well-deserved vacation. In a world increasingly driven by automation, your website's content publishing should also be automated from day one.
For Drupal users, there are a few ways to tackle this, but the most popular and robust solution by far is the Scheduler module. With over 96,000 reported installs, as of this writing, and a history spanning back to 2006, it's a proven workhorse in the Drupal ecosystem. I’ve been personally installing this community module on nearly every Drupal site that I work on because, if for no other reason, I use the functionality frequently. It's time to let your website do the heavy lifting while you focus on creating brilliant content or, better yet, taking a break!
What It Is And What It Does
The Scheduler module is your digital content clock. At its heart, it provides a straightforward, powerful way to automatically publish or unpublish any piece of content at a specific future or past date and time. No more setting calendar reminders, no more logging in at odd hours, and certainly no more accidentally publishing early or late.
Born in 2006, Scheduler has matured over 19 years as a Drupal project, benefiting from countless bug fixes and enhancement contributions from nearly 100 community members. This long history and strong community backing mean it's incredibly stable and reliable. Its core function is simple yet transformative: once you set a publish or unpublish date, Scheduler takes care of the rest, ensuring your content appears and disappears exactly when it should.
Think of the possibilities:
- Strategic Content Rollouts: Launch an article exactly when your marketing campaign hits, even if you're asleep.
- Seasonal Campaigns: Have holiday promotions go live and expire automatically.
- Time-Sensitive Information: Ensure event details publish promptly and then unpublish once the event is over.
- Peace of Mind: Enjoy your time off knowing your content strategy is still ticking along perfectly.
Installation
Getting Scheduler up and running is just like adding any other module to your modern Drupal site. If you're using Composer, which you absolutely should be, it's a quick command: composer require drupal/scheduler
Once that's done, you can head over to your site's Extend page (/admin/modules) and enable the Scheduler module. For more detailed instructions or specific version requirements, always check the official module documentation on Drupal.org – it's your best friend!
Module Configuration
After enabling Scheduler, you'll want to take a quick peek at its global settings. You'll find these under Configuration > Content Authoring > Scheduler settings (/admin/config/content/scheduler). Here, you can define some site-wide behaviors:
- Default publishing/unpublishing options: Set up standard behaviors for how dates appear and what happens if a date isn't entered.
- Messages: Customize the messages users see when content is scheduled.
- Date formats: Choose how the scheduling dates are displayed.
These general settings provide a solid foundation, but the real magic happens when you configure specific content types.
Entity Scheduling Configuration
Scheduler isn't just about the module itself; it's about how it empowers your content types (or "bundles" in Drupal speak) to be schedule-ready. While it works beautifully with standard nodes (like your articles or basic pages), its power extends to custom entity types too.
Supported Entity Types
Out of the box, Scheduler works seamlessly with nodes, which are the most common type of content on a Drupal site. This includes all your standard content types like "Article," "Basic Page," "Blog Post," or any custom ones you've created. But here's where it gets interesting: Scheduler is also designed to be highly extensible, allowing it to work with other custom content entities you might have on your site, like products, events, or even custom media types.
Configuring Node Bundles for Scheduling
To enable scheduling for a specific content type (like your "Blog Post" bundle), follow these steps:
- Navigate to Structure > Content types (/admin/structure/types).
- Click "Edit" next to the content type you want to schedule (e.g., "Article" or "Blog Post").
- On the content type's edit page, click on the "Scheduler settings" tab.
- Here, you'll see options to enable "Publishing options" and "Unpublishing options." Check the boxes for the functionality you need.
- You can also set default dates (e.g., "now") or specific time increments, and even decide if published content should automatically be unscheduled.
- Don't forget to Save content type!
Once saved, any time you create or edit content of that type, you'll see two new fields: "Publish on" and/or "Unpublish on" fields under the "Scheduling options" section in the sidebar. This is where your content managers become scheduling ninjas!
Scheduling Nodes for Publishing
Now for the fun part! With your content type configured, scheduling content is as easy as filling out a form:
- Create a new Node, or edit an existing Node.
- Locate Scheduler Fields: Scroll down and you'll see the "Scheduling options" section in the right hand sidebar. There you will see those handy date and time fields for publishing and/or unpublishing your content.
- Set Your Dates: Use the calendar pop-up and time selector to choose the exact moment you want your content to go live or disappear.
- Save: Once you save your content, Scheduler takes over. The content won't appear or disappear until the precise moment you've defined. It's truly "set it and forget it."
Scheduling Custom Entity Types
Drupal's power lies in its flexibility, and Scheduler embraces this fully. While out-of-the-box it works with nodes, developers can extend Scheduler to work with virtually any custom content entity on your site. If you have unique entity types for, say, "Testimonials," "Job Postings," or "Product Releases," your development team can implement a few simple hooks or interfaces to integrate them with Scheduler.
This means you get the same powerful automated publishing and unpublishing for all your unique content assets, not just standard pages. It keeps your content consistent across the board and further reduces manual intervention. It might require a little developer voodoo, but the long-term gains in efficiency are well worth it.
The Silent Orchestrator: Cron
"Okay, so I've set the dates, but how does Drupal magically know when to publish or unpublish?" That's a brilliant question, and the answer is Cron. Cron is Drupal's internal task master – think of it as your site's trusty internal alarm clock. It regularly ticks away, telling modules like Scheduler when it's time to check for pending tasks and execute them. Scheduler absolutely relies on Cron to perform its automated publishing and unpublishing actions.
For many smaller sites, or those hosted on shared servers without straightforward access to set up a robust server-side cron job, the Lightweight Cron module is a fantastic, worry-free alternative. This clever module quietly triggers Drupal's Cron whenever someone visits your site, discreetly running those scheduled tasks in the background. It's a simple, effective way to ensure Scheduler (and any other Cron-dependent modules) always run without you needing to lift a single finger.
However, for larger, high-traffic websites, relying solely on Lightweight Cron can sometimes be inefficient or lead to delays, as it only runs when a user visits a page. For optimal performance and absolute reliability, especially for critical tasks like content scheduling, always prioritize setting up a proper server-side cron job.
Setting Up a Server-Side Cron Job with Drush (Recommended)
For Drupal 8 and newer, Drush is the go-to command-line tool for managing your site, and running cron is one of its core capabilities. Using Drush for cron is more robust and generally preferred over HTTP-based methods (wget
, curl
) as it directly executes Drupal's internal cron process.
1. Ensure Drush is Installed and Working:
You'll need SSH access to your server and Drush installed via Composer within your project. Test it by running drush status
or drush cr
from your Drupal root directory. If you get a “command not found” error, you may need to add the vendor/bin directory inside your Drupal root directory to your $PATH
shell variable.
2. Access Your Server's Cron Tab:
- cPanel/Web Hosting Control Panel: Many hosting providers offer a "Cron Jobs" or "Scheduled Tasks" section in their control panel. You'll enter the Drush command here and specify the desired frequency.
- Command Line (SSH): If you have direct SSH access, you can edit your user's crontab by running the crontab -e command.
3. Add the Drush Cron Entry:
The most common way to run Drush cron from your crontab is to navigate to your Drupal root directory and then execute the drush cron command.
A typical crontab entry to run Drush cron every hour would look like this:
* * * * * cd /path/to/your/drupal/root && /path/to/drush/executable cron > /dev/null 2>&1
Let's break that down:
* * * * * *: This part defines the schedule (every minute of every hour, every day, every month, every day of the week).
cd /path/to/your/drupal/root: Crucially, replace this with the actual path to your Drupal installation's web root. This ensures Drush runs from the correct directory.
&&: This operator executes the next command only if the first one (changing directory) is successful.
/path/to/drush/executable cron: Replace /path/to/drush/executable with the actual path to your Drush executable. If Drush is installed globally and in your PATH, you might just use drush cron. If it's a Composer-managed project, it's often ./vendor/bin/drush cron.
* > /dev/null 2>&1: This is important! It redirects all output (standard and error) to /dev/null, preventing your server from sending you an email every time cron runs.
HTTP-based Cron (Less Preferred for Modern Drupal)
While Drush is highly recommended, in rare cases where server access is limited or Drush isn't an option, you might still use an HTTP-based method:
1. Find Your Drupal Cron URL:
In your Drupal admin interface, navigate to Configuration > System > Cron (/admin/config/system/cron). You'll find a unique URL with a security token, e.g., https://www.yourdrupalwebsite.com/cron/your_cron_key.
2. Add the Cron Entry:
Using wget or curl in your crontab:
0 * * * * wget -O - https://www.yourdrupalwebsite.com/cron/your_cron_key > /dev/null 2>&1
Remember to replace the URL with your actual site's cron URL.
Implementing a dedicated server-side cron job, especially using Drush, provides superior performance and ensures the utmost reliability for your critical automated tasks, giving Scheduler the consistent heartbeat it needs to keep your content flowing precisely as planned.
The Power of Automation at Your Fingertips
Embracing the Drupal Scheduler module isn't just about convenience; it's about smart, strategic content management that empowers you and your team. It genuinely frees up your valuable time, virtually eliminates human error in publishing times, and allows you to plan and execute content initiatives with unparalleled precision and confidence. Imagine a world with no more midnight alarms, no frantic last-minute logins, and a content calendar that manages itself!
So, are you ready to bring true, effortless automation to your Drupal content strategy? Dive in! Install the Scheduler module, configure your content types, and experience the unparalleled freedom of knowing your content is always exactly where it needs to be, precisely when it needs to be there. Give it a try – you won't look back!
What are your biggest content scheduling challenges? Share your thoughts and success stories with Scheduler in the comments below!
0 Comments
Login or Register to post comments.