A while back on mooey5775, I posted an article on fixing WP-Cron by manually calling the wp-cron script. However, when setting up ed.ward, I noticed that something was wrong. According to cron logs, the wget job was being executed. However, scheduled posts weren’t actually being posted when I wanted them to be.
That’s when I found the plugin WP-Cron Control. In this article, I’ll take you through fixing WP-Cron the new way.
WP-Admin Installation
The first step is, obviously, install the plugin. WP-Cron Control installs just like any other plugin. For the users that want to install it manually, it’s located here. The plugin thumbnail might seem slightly sketchy, but the authors are from Automattic, which is the company that created WordPress.
After installing and activating the plugin, there are a few things you need to configure. WP-Cron Control lives under the Settings menu.
Once you’re there, there’s a few things that you might want to change. If you want to make sure your scheduled posts are on time, every time, it would be a good idea to enable scheduled post validation.
You should also take note of the wget command that is provided to you on the page. Copy the URL that is provided to you for later.
Server Configuration
The next thing you need to do is actually create the cron job on your server or any computer that you have access to and you know is always on. If you use shared hosting, there is usually a way to set up a cron job within cpanel or whatever your hosting provider uses. Because of the variety of hosting providers, it would be best to contact them and ask how to create a cron job.
However, if your website is self-hosted or you want to use a separate computer to run the cron job, the easiest way to edit your crontab is via the command line. As always, editing your crontab can be accomplished with this command:
crontab -e
I prefer to execute WP-Cron every 15 minutes to avoid putting unnecessary load on my server. This can be accomplished by executing a wget command in your crontab.
This command should do the trick:
*/15 * * * * wget -q -O - {COPIED_URL} > /dev/null 2>&1
Basically, the first part schedules this command for execution every 15 minutes. Then wget is run in quiet mode, so no output is generated. We don’t want to actually download the URL from your website, so the downloaded website is piped to stdout using -O -.
Then, stdout is piped to /dev/null with > /dev/null 2>&1
, essentially getting rid of all output.
Now, save and exit the text editor (on nano, it’s Ctrl+X, y, Enter
).
Testing
This is the easy part. To test your WP-Cron configuration, just schedule a post for sometime in the future, hopefully within a reasonable timeframe. Come back when your post should be there, and hopefully, it is!
If you had any problems, check the commands that you entered. If it still doesn’t work, let me know through the comments.