M3Server Technical Blog FAQ Disable WordPress Cron

Disable WordPress Cron



How often should wp-cron.php run?

How often do you update or tend to your website?

As a rule if you only check your website once a day, then run wp-cron.php once a day. If you find that you are getting a LOT of spam comments and Akismet is not keeping on top of it, then you may want to set it to every 6 hours or so.

Even if you were constantly working on a very busy site you would probably only want things to be processed every 30 minutes at the most.

WordPress tries to schedule its own activities using a wp-cron.php script. Unfortunately this script gets called to run every time a visitor comes to your site and can cause high usage.

You should setup a cron job that will only call wp-cron.php less often, something like every 4-6 hours works well.

0 */5 * * * cd /home/username/public_html; php -q wp-cron.php
*     *     *   *    *        command to be executed
-     -     -   -    -
|     |     |   |    |
|     |     |   |    +----- day of week (0 - 6) (Sunday=0)
|     |     |   +------- month (1 - 12)
|     |     +--------- day of        month (1 - 31)
|     +----------- hour (0 - 23)
+------------- min (0 - 59)

Then you’ll want to open up your wp-config.php file and add the following entry to it to disable the default wp-cron from running:

/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');

define('DISABLE_WP_CRON', 'true');

The disable line must be before this statement:
/ That’s all, stop editing! Happy blogging. /

Like so:

define(‘DISABLE_WP_CRON’, ‘true’);
/ That’s all, stop editing! Happy blogging. /

If you need help adding a crontab we can add one for you.

Leave a Reply