Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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 

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

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top