Cron Intervals

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 feeds every 15 minutes, or every hour, etc. Custom intervals can also be set. Are your feeds not importing? Chances are you are having problems with the WordPress cron system.

Cron is a system originally built for UNIX that enables users to execute commands, programs and other actions at specified times. As Wikipedia so eloquently puts it, “Cron is a time-based job scheduler.” Basically, what that means is you can schedule an action to take place at a specific time, without having to manually execute code at that time.

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

  1. A time tied to an action occurs.
  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 the scheduled time has passed.
  3. If the scheduled time for that event has passed, then 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
  • and more!

Unlike regular cron jobs, which run at specific time based on the server settings, the WP-Cron function runs every time someone visits the WordPress powered website. This makes a WordPress site run properly on different kinds of server setups because it eliminates a lot of server-specific requirements. 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 because some jobs might take more time and the user requesting the WordPress page cannot be made to wait. Calling the wp-cron.phphelps keep the WP-Cron function running as a separate process in the background without delaying the page load time for the user. 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.

The most common reason for feeds not importing 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 no imported items/posts. How can you determine if you are having problems with cron? Easy, download 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
Good Cron

If they are all stuck running now (as in the screenshot below) then you are having problems.

Bad Cron
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 see exactly what the problem is.

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 on that day, the cron job that fetches feeds for that source will only be triggered once during that day. So, consider the impact of no visits. If a website gets no traffic at all, then 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.

To make sure you’re not affected by the limitations of WordPress Cron, you can define real cron jobs to run. How do we do that? Note: Your hosting provider has to have cron support for this to work, not all of them provide this, especially shared hosts.

1. Disable WP Cron

In your wp-config.php file, add the following line:

This will now stop the internal WP-Cron function from executing and will not call the wp-cron.php file. What you’re disabling is WordPress’ built in functionality for firing its cron jobs on every page load.

2.  Setup a Server Cron Job

Next, simply 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 are running within the context of a cPanel-based web host. Some are simply running on an internal server or something similar where all you have is access to the command line. And 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:

Next, add the following line into the cron file:

Of course, you’ll want to change up 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, but this will trigger an event to fire every 15 minutes that will 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.
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 sever, 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. EasyCron also provide a WordPress plugin for easily setting up cron jobs with their service. Some recommended online cron sites are: