In this video we will create an article, and schedule it to be published in the future. Then we’ll see how Scheduler uses cron to publish and unpublish content.

Creating an article with scheduler

Now that the article content type can be scheduled, let’s go back and create an article to see what scheduler has added.

  • Go to “Content => Add content => Article) “node/add/article”
  • Title: Test Article #2
  • Body: Lorem ipsum...

This time when we scroll down, we have a new vertical tab, “Scheduling options”. I’m going to schedule this for one minute in the future to see how it works.

  • Publish on [date/time]
  • (Save)

Now, at the top of the page we get a couple of notices. One is the standard message that says the article has been created, but there’s a new one that says that the post is unpublished and when it will be published.

If we go home, we won’t see the new article because it hasn’t been published yet. I’ll come back in just a minute after the time I scheduled it to publish.

...

Okay, now when we refresh the page, you’ll notice that the article still hasn’t shown up. This is because Scheduler utilizes Cron to publish and unpublish content. Right now, Cron is set to run every three hours, so I’ll go ahead and run it manually to publish the content.

And now that cron has run, when I refresh, the article is published. So it is important to realize that even though you schedule something at a specific time, it will actually publish when cron runs. So if you schedule something to publish at 1:00, but cron doesn’t run until 2:00, the article will actually be published at 2:00, while the published date will say that it was published at 1:00.

You can create a separate cron schedule specifically for the Scheduler module so that it can check for content that needs to be published and unpublished on a more frequent basis, without running the full Drupal cron. We’ll take a look at how to do that in a later video.