0

I have a low traffic WordPress (4.5.3) site at http://brandgrowmedia.ca/.

When a blog post is scheduled, it frequently (~80% of the time) does not post and is marked as "Missed schedule". I looked into the problem and believed it was related to a cron task not firing because the site did not have enough traffic

In an attempt to fix the problem, I installed the plugin WP-Cron Control. As per the plugin's instructions, I then logged into my cPanel and and set up a cron job that called the appropriate function. However, this did not seem to have any effect and the post is still marked as "Missed schedule" most of the time.

Screenshot of cron job in cPanel

Cron Job

Screenshot of plugin settings page

Plugin settings

Can anyone help?

  • 1
    What exactly had you set up in cPanel? Had you inquired with plugin's developers? – Rarst Jul 21 '16 at 16:46
  • @Rarst Here is a screenshot of the cPanel set up (as per the plugin's instructions) -awesomescreenshot.com/image/1415561/…. – zgall1 Jul 21 '16 at 16:59
  • @Rarst I will try the plugin support forum for the specific plugin now. Thanks for the suggestion. – zgall1 Jul 21 '16 at 17:00
  • The link to screenshot doesn't work for me, please upload screenshots to your post, that usually works best. :) – Rarst Jul 21 '16 at 17:00
  • @Rarst Screenshot added – zgall1 Jul 21 '16 at 17:04
3
+50

You don't really need a Plugin to define these type of cronjobs in a timely manner. All you need to do is to reliably call the Wordpress Cron file which is wp-cron.php

The question is if your Webhost allows you to start wget without any path command or if it's allowed to start it anyway.

I would first of all try calling example.com/wp-cron.php manually when a post is missed to check if this solves your problem. Therefor you should uninstall any cron plugins and disable the wordpress style poor men's cron in the wp-config.php by adding

define('DISABLE_WP_CRON', 'true');

to it and then try it out.

If this works I'll try the webhosters cron function (but without any of the parameters on the URL that the cron plugin gives you). If your site is on SSL you might want to add `--no-check-certificate' to avoid problems here. Here's an example cronjob

*/2 * * * * /usr/bin/wget -q -O /dev/null --no-check-certificate https://example.com/wp-cron.php

Explanation:

  • */2 * * * * means every second minute on every hour of the day and every day.
  • /usr/bin/wget calls the program wget from its origin - that depends on your provider/server
  • -q -O /dev/null silents the output and pushes everything to /dev/null if there is any
  • --no-check-certificates ignores certificates for https calls and avoids problems here.

If you still encouter problems even when manually calling this URL there may be some issues with caching on your site. If you are using a caching plugin of any sort or your provider is using proxies you should probably try to test without those things active to avoid any problems there.

2

I had some issues with publish_future_post not firing. I looked into it, and in my case it was the Jetpack Sitemap generator not returning to wp-cron.php. And so any hooks due now after the Jetpack Sitemap generator hook were not firing at that time. So, one possible reason is a misbehaving hook. Using WP Crontrol plugin I changed the time for the Sitemap generator to fire to a time after when my client would schedule a post to publish. This worked, but then for a reason I never could figure out it happened again. So, since I had access to WP CLI on my host and I was already running a script to take care of site tasks, including running wp-cron.php, I used the wp cli to run the publish_future_post hook. The pattern I follow is below; you can adapt it for your needs. The function associated with publish_future_post has a safety check not to publish a post early, but is is safest to use --due-now. Since WP CLI was already installed on my host I cannot give directions on how to install it; perhaps someone else here can provide some information.

# directory where WordPress files are installed. wp reads wp-config.php.
# This directory may be different for you
cd $HOME/public_html

# --due-now ensures only schedule posts ready to post will be published
# you could add --path=<path to wp files> instead of using line above but I 
# think for the next line to work you need to be where your WordPress files are
# The directory for wp may be different for you
/usr/bin/wp cron event run publish_future_post --due-now

# Run other cron events normally. The directory for php may be different for you
/usr/local/bin/php wp-cron.php 
  • what about wpcli with --path instead of your cd line ? – birgire Jul 24 '17 at 23:28
  • That would work too. I'll add it. – Gary Hall Jul 25 '17 at 12:21
-1

You could also use a webcron. A site or service that calls your domain in an interval. Kind of of like a "fake" visitor.

  • You mean like this? mywebcron.com. I am willing to try this as a last resort but I would rather get to the root of the problem if possible. To be honest, while I have looked up cron to better understand how it functions, I don't really even understand why a low traffic website would have this problem. – zgall1 Jul 21 '16 at 17:10
  • You have this problem because wordpress uses "fake crons". Crons usually run on the server - independent on visitors, like the one you created. WordPress uses something else but calls it cron. Whenever a visitor visits your site, WP triggers the cron function. No visitor = no triggering the function. – dpoakaspine Jul 21 '16 at 17:19
  • Here's what I don't understand. Does the visitor trigger the post to get assigned to a cron job and run at a future date or does the visitor trigger the actual posting of the scheduled post? – zgall1 Jul 21 '16 at 17:48
  • The visitor triggers a cronjob function in WordPress which searches the database for jobs. In this job database are multiple post entries for future publishing or other actions. Plugins can hook into this system and create their own jobs. – dpoakaspine Jul 21 '16 at 18:23
  • Thanks for clarifying. I wonder why this plugin is not working given its relative simplicity. – zgall1 Jul 21 '16 at 19:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.