[Back to Docs]

How to enable your WordPress Cron System

What is the WordPress Cron System?

The WordPress Cron System allows WordPress sites to passively process information in the background. When visitors (or spiders) visit your website WordPress checks it’s cron system to see if there are any jobs scheduled to run and runs them if needed. Within this system developers can design routines to run every X minutes, hours, or days if needed.

This is great for handling scheduled routines such as tweeting tweets or removing garbage data.

How to enable:

  1. The WordPress Cron system ships enabled by default, but sometimes, for some reason or another, it can get manually disabled.
  2. To re-enable the cron system open your wp-config.php file located in the base root of your WordPress directory and look for a PHP Constant named DISABLE_WP_CRON and set it’s value to false.
define('DISABLE_WP_CRON', false);

If you do not see a DISABLE_WP_CRON constant inside your wp-config.php file and still believe your cron system to be disabled then the next location you should probably check is your active theme’s functions.php file.

How to disable:

To disable the WordPress cron system open the wp-config.php file in your root WordPress directory and add this line:

define('DISABLE_WP_CRON', true);

Why does TweetBoostPro need it?

Because TweetBoostPro helps users to schedule tweets to publish at future timestamps we offload our scheduling checks onto the  WordPress Cron System, which we use to check for new tweets to publish every two minutes.  This ensures that our users can implement “set-and-forget” practices with their Twitter marketing campaigns.

Remember! WordPress’s cron system is powered by site activity/traffic. If your site has no activity/traffic then your schedules will not run on time. For most site, organic spider activity should be enough to power your schedules.

For local sites you may have to get more creative.

How to make sure Cron runs locally:

If you are running TweetBoostPro locally then most likely you are going to find that lack of traffic to your site is causing tweets to miss their target schedules. You may ask, “How do I get around this?

There’s a few ways you can stimulate your local site’s cron system.  One is easy, and the others are a little more advanced.

The easy way:

The easiest way to make sure your local cronjobs are being stimulated is to always have a browser tab open that’s logged into your local WordPress Dashboard.

When logged in WordPress will run a background command every minute called a “heartbeat“. This heartbeat will make sure your cron system is periodically run every minute and your tweets fire on schedule.

So if you intend to use your local machine to power an automated Twitter account, just make sure your dashboard is always loaded and you should be fine.

The Scheduled Task Solution:

Another alternative is to write a custom batch script (Windows) and then use a Task Scheduler to automatically open your local site every X minutes. We do not have the code to do this readily available, and the code/setup-process may change depending on what OS you are using so we’ll leave implementation of this solution up to you.  Here’s a few links that might help you on your journey if you take this path: [1] [2]

The Node JS Solution:

A lot of really cool things can be done with a custom NodeJS server! In this concept (which we approach more as an abstact concept) we would use a custom Node script that opens your website without launching a browser every X minutes. Although we do not have an example script built, we feel that if you are comfortable enough to work with NodeJS then you will have no trouble at all developing a custom solution.

If you have a different or unique solution feel free to share it with us or let us know about it and we’ll link to it here!