0,00 $

No products in the cart.

Home » WordPress and Blogging » WordPress Tutorials » Let’s Talk About WP-Cron
0,00 $

No products in the cart.

Let’s Talk About WP-Cron

WordPress' wp-cron.php is responsible for running scheduled tasks on your WordPress website but, as usual, much can go wrong!

I recently had some issues with this myself! Here's more about the WordPress cron system and some things you might try if you have WordPress cron problems.

& You May Like:

Having Trouble Saving Social Statuses in a WordPress Plugin? That Emoji Might Be to Blame!

Is your social plugin not saving your statuses? The culprit may be that emoji -- or the number of characters in it. Note that my "solution" here is kind of a non-solution and I invite anyone to offer a better one than picking and choosing emojis.

Currently Reading

Nine Nasty Words

0
(0)

WordPress’s system for running regularly scheduled jobs (via a file called wp-cron.php )is fresh on my mind right now after finding that regular WordPress tasks weren’t running. When you have WordPress cron problems, you might see a warning at the top of your admin or in WordPress Site Health that tells you a scheduled event has failed.

So, what to do about this? In my case, I already had a handle on wp-cron and had set up server-level cron jobs, so this issue sent me to Angertown.

I’ll say right away that my issue was that I had recently upgraded to PHP 8.0 after what I thought was the last hold-out plugin got updated. But then I found that on some of my sites, cron jobs weren’t happening. After checking everything I could think of, I finally asked my host and found that wp-cron generated a critical error. I did the usual task of disabling plugins but couldn’t seem to find the culprit. For now, I pulled back to PHP 7.4 — issue solved! But after a long day of headaches.

But read on for more info about wp-cron and some of the things I’ve tried.

What is wp-cron?

If you look in your WordPress install, under your public_html directory (or whichever folder you have WordPress installed), you’ll find a file called wp-cron.php. This file is responsible for running scheduled jobs set up by WordPress and by your various plugins. Essential things such as scheduled posts getting published, checking for plugin updates, doing database cleanups if you have an optimization plugin–the list goes on.

The problem is, sometimes it doesn’t work.

Why would wp-cron not work?

Low traffic – wp-cron.php not triggered

The default for WordPress is that a visit to your website triggers wp-cron.php. For low-traffic websites, this means that it sometimes doesn’t get triggered when it needs to. For instance, you’ve scheduled a post, nobody visits, and it fails to publish on time.

High traffic – wp-cron.php as a source of high CPU usage

So you have a lot of regular visitors and think you have nothing to worry about, right? WRONG!

If you have many regular hits on your website, it means that wp-cron.php is always getting triggered. This behavior can lead to other problems.

I was having mysterious high CPU problems for a while. A minor culprit in this was wp-cron.php 1.

Some ways to solve wp-cron issues

Disable cron jobs from “spawning” and set up a server-level cron

Yep, cron jobs “spawn.” But you can stop this behavior by adding the following to your wp-config.php file 2:

define('DISABLE_WP_CRON', true);

You add this just above the line that says /* That’s all, stop editing! Happy blogging. */. You’ll probably see a bunch of similar things that also start with define.

Doing so will stop those cron jobs from spawning. Which will mean scheduled tasks WILL NOT run. So we need to do something to make sure that they do run, but that wp-cron.php can’t just spawn wildly on your website!

To do that, you’ll need to go into your hosting account. In cPanel 3 and other platforms I’ve encountered, you will find a setting having to do with cron. Ask your hosting provider if you cannot find it.

Most hosts I’ve encountered have a setup where you can choose the interval and the file you wish to trigger (which will be wp-cron.php).

In my hosting panel at Cloudlways, there’s also an “advanced” area for setting up a manual cron job.

Setting up a manual cron job looks something like this:

*/5**** wget -q -O /dev/null "http://example.com/wp-cron.php" > /dev/null 2>&1

But I can’t find where to set up a manual cron job for my server!

If you cannot find where to easily set up a cron job, no prob!

EasyCron has a free cron service, and it’s straightforward to use.. You just create an account, set up timing for your cron job, and set the URL as https://www.myurl.com/wp-cron.php 4.

I’ll note that none of these methods worked in my case as triggering wp-cron.php itself resulted in an error.

How often should I set up cron jobs?

My website has not suffered from having a hit to wp-cron.php every 5 minutes, even though some tasks have an “every minute” schedule. Some even suggest every 15 or 30 is OK.

Some shared hosting providers may have restrictions, as well.

I am still having WordPress cron problems !

Isn’t it frustrating?

A few plugins might (or might not) help you weed out what’s causing your issue. 5

Plugins to Help Diagnose WordPress Cron Problems

I’ve tried a few of the cron plugins available in the WordPress plugin repository.

WP Crontrol

WP Crontrol is the most popular of these plugins. Set it up, and you can view a list of all of the scheduled tasks set up to run on your WordPress website. You can then run each one immediately, edit their schedule (but only do so with great caution). I even found and deleted a few tasks left over by uninstalled plugins. It’s a good way to find out which jobs are getting missed.

Advanced Cron Manager

Advanced Cron Manager is very similar, from what I’ve experienced, to WP Crontrol. In trying to diagnose my issue, I even tried their Pro version because it would log errors. I ended up asking for a refund, however. The plugin is excellent, but it didn’t log the errors generated by my websites in my specific situation.

WP-Cron Status Checker

This plugin checks every 24 hours to see if wp-cron can still run and notify you if it isn’t able to. So if you’re not logging on to your website every day, this can give you some peace of mind.

HAVE YOU DISABLED YOUR PLUGINS?

Don’t you hate it when you contact support, and they say that? It’s my version of, “you’ll shoot your eye out, kid!”

When they say this, I usually have done this and done this several times.

But they say it for a reason. Sometimes a rogue plugin or a conflict between plugins is the cause of problems with wp-cron. A plugin was the issue in my case, as when I disabled ALL plugins, wp-cron started to operate normally again. However, I could not tease out which plugin was the cause, even after looking at error logs.

As I said, there was some incompatibility with PHP 8.0 and an unidentified plugin. So I’m waiting a while.

Should you use alternate cron to solve WordPress cron problems ?

Something described in this post by Jeff Starr was successful in getting cron jobs to run on my website without reverting my PHP version or disabling any plugins 6:

He advises to just put this in wp-config.php:

define('ALTERNATE_WP_CRON', true);

Using alternate cron worked beautifully, except for one thing that he warns about: that sometimes your URLs end up with a long string at the end like this: ?doing_wp_cron=26492012-329-012.23743840839483092834.

This sometimes was every time on my website, and these long URLs were a deal-breaker for me.

Now, after pulling back my PHP version, cron jobs are running fine, I’ve resumed my server-level cron job, and all is good. Until the next problem arises. Such is often life with WordPress. But I still love it.


That’s it, my diatribe on wp-cron.php. Please post a comment if you know of something else I haven’t mentioned here.

Fortunately, my WordPress cron problems are solved for now. Hopefully, they won’t recur when I finally move back to PHP 8.0.

How many hot cups of coffee does this post or page deserve?

Click on an icon to rate it. If this is a review post, you might find a widget to rate the item itself at the beginning of the post. If this is a product, please leave your product rating under the review tab.

Average rating: 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

As you found this post useful...

Why not share it?

We are sorry that you found this post to be like a weak cup of decaf.

Let us improve this post!

Tell us how we can improve this post?

References and Footnotes
  1. The major culprit, I found was that I had backup plugins that were doing their thing all around the same time — changing the timing AND changing the way I did wp-cron solved the issue.[]
  2. Your wp-config.php file is located at the root of your website — whatever folder you have WordPress in. Usually, this is public_html.[]
  3. Which I don’t have right now so I cannot take a screenshot.[]
  4. Where myurl.com is your domain, of course![]
  5. Don’t know how to install a plugin? You probably do if you’re having WordPress cron problems. But if not, you can read this post.[]
  6. However, I would still have wanted to tease out where the errors were occurring.[]
Get Notifications by Email

Sign up for our email newsletter and keep up to date on new additions to our website.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
Share this
0
Hi there. While you're here, care to comment?x
()
x
Send this to a friend