What is WordPress Cron, Why Do I Need It, and What Are the Alternatives?

With WP RSS Aggregator, you can set a feed update cron interval as a general setting, or even on a per-feed-source basis.

What this means is that you can set a feed source to fetch new feed items every 15 minutes, every hour, or how often you'd like. Custom intervals can also be set. 

What is a Cron?

Cron was a task scheduler system originally built for UNIX to enable users to execute commands, programs, and other actions at specified times. 

This means you can schedule an action to take place at a specific time, without having to manually execute code at that time. 

What About WordPress Cron?

WordPress Cron is what many people refer to as a “pseudo-cron system.” The difference is in how UNIX Cron and WordPress Cron get into action. A typical UNIX cron system runs in this order:

  1. A time tied to an action is reached.
  2. Cron runs the action tied to that time.

With WordPress Cron, it works a little differently:

  1. A visitor comes to any page on your WordPress website.
  2. WordPress Cron checks each cron event to see whether its scheduled time has passed.
  3. If the scheduled time for that event has passed, WordPress Cron executes any actions tied to that event.

As WordPress is installed on so many different setups, to make things run properly, WordPress developers implemented this pseudo cron system that helps run scheduling jobs such as:

  • Checking for theme & plugin updates
  • Publish scheduled posts
  • Sending pingbacks

Unlike regular cron jobs, which run at a specific time based on the server settings, the WP-Cron function runs every time someone visits the WordPress-powered website. This allows a WordPress site to run properly on different kinds of server setups because a lot of server-specific requirements are eliminated. 

On every page load, WordPress checks if there is a need for WP-Cron to run. If there is a need, then it tries to make a request over HTTP to the  wp-cron.php file. The reason to call wp-cron.php is that some jobs might take more time and the user requesting the WordPress page cannot be made to wait. Calling the wp-cron.php helps keep the WP-Cron function running as a separate process in the background without delaying the page load time for the user. 

When a visitor visits your site, WordPress takes up a CPU thread in order to complete the page load. If WP Cron needs to run, it will do so on its own thread, so that the visitor's thread is not slowed down by WP Cron. However, if all threads are taken up, either WordPress or WP-Cron will need to wait for one to be free. If your site has low traffic, several pending cron tasks can be queued up for a long time, thus causing an increase in page load times.
You will need to review how many CPU threads are made available with your hosting plan to ensure your site runs smoothly.

Once the WP-Cron function starts, it continues to run until all the required jobs are completed or until it reaches an execution time as set in the server configuration.

What is Bad Cron?

The most common reason for feeds not importing automatically is a stuck cron system. 

We’ve seen it time and again. WP RSS Aggregator would be set up perfectly but all the importing cron jobs are getting stuck, thus resulting in no imported items/posts. 

How can you determine if you are having problems with cron? Easy, download and install  WP Crontrol, a free plugin from the WordPress.org plugin repository. Then head to Tools > Cron Events and you will see a list of cron jobs. This is how a normal cron job list should look like:

Good cron

If they are all showing now (as in the screenshot below) this means the cron jobs are stuck.

Bad Cron

The easiest way to get this issue solved is to contact your host, explain the situation, and even provide a link to this page so that they can understand the exact problem.

Limitations of WordPress Cron

You may be wondering, “What happens if no one visits my website at all? Does WordPress Cron not run?” The biggest limitation of WordPress Cron stems from its inability to run without visitors. This leads to a few potential issues.

WordPress Cron is Imprecise (Zero Visits = Zero Cron Runs)

If you’ve scheduled a feed source to update every 15 minutes, but you only get one visitor every few hours, the cron job that fetches feeds for that source will be triggered only once in several hours. 

So, consider the impact of no visits. If a website gets no traffic at all, WordPress Cron will never run. Of course, we hope your website will be getting many visits, however, this is a consideration to keep in mind, especially for new sites that are still building their traffic base.

Getting Around the Limitations

Before attempting the instructions below, please try the alternative (and simpler) solutions here.

To make sure you’re not affected by the limitations of WordPress Cron, you can define real cron jobs to run. Read on to know how.

IMPORTANT: Your hosting provider has to have cron support for this to work. Not all of them provide this, especially shared hosts.

Set Up a Server Cron Job

Request  wp-cron.php directly using cron. For more information on cron, the Wikipedia article is a good starting point. 

Most web hosts provide an interface for defining cron jobs, but not all applications will be running within the context of a cPanel-based web host. Some will be simply running on an internal server where all you have is access to the command line. Considering that the cPanel is nothing more than a GUI to the command line, here’s what you need to know to define a cron job at the operating system level:

buffer_0 > crontab -e

Next, add the following line to the cron file:

*/15 * * * * wget -q -O – http://yourdomain.com/wp-cron.php?doing_wp_cron
Of course, you’ll want to replace yourdomain.com with the domain for your own purposes. 
The complete guide to the cron commands and tools such as wget is outside the scope of this article.
The cron you set up above will trigger an event to fire every 15 minutes and make a request to your WordPress website, thus kicking off any scheduled tasks. If you have cPanel installed in your hosting environment and prefer to set up your cron jobs through it, here’s a good guide.
Please consult your hosting provider's documentation for information on setting up a cron.

NOTE: This runs well for general WordPress websites. For those using a WordPress network (multisite), there might be additional things required (hitting wp-cron.php will need to happen for every site). Check out this article for some ideas.

Yet Another (Easier) Alternative

Instead of setting up cron using your server, you can use one of the many online cron services. All you have to do is sign up with them and set a time interval for them to ping your  wp-cron.php file. This is a very popular method of kickstarting WordPress cron. 

In fact, the EasyCron.com website has a  special guide for WP RSS Aggregator users, giving a step-by-step procedure for setting things up.    

Some recommended online cron sites are:

IMPORTANT: Please note that we do not provide support for these services, nor do we guarantee that they will work at all times, with or without WP RSS Aggregator. Any changes made to your WordPress site's cron system should first be discussed with your hosting company or an experienced developer.

Still need help? Contact Us Contact Us