Support » Fixing WordPress » wp-cron.php Running Despite DISABLE_WP_CRON

  • Hi

    I am experiencing some very annoying and strange issues with wp-cron.php on my website.

    It all started when I noticed high CPU usage on the server, and then tracked it down to the issue of wp-cron.php spawning on every page view. I discovered that we’re supposed to be able to stop that by defining the DISABLE_WP_CRON constant in the wp-config.php file and scheduling a proper cron job in the server control panel, which I did.

    My hosting company support checked out what I did, and agreed that it was set up correctly.

    However, wp-cron.php still spawns every time a page is accessed on the site, whether by a visitor or a bot, to the extent that it accounts for more than 50% of the CPU usage on the site.

    The hosting support folks can’t explain it, and they don’t know how to prevent this from happening, so I thought someone here might know.

    I’ve searched all the code in all of my plugins (active and inactive) for any reference to wp-cron.php with no luck, so I don’t think any of those are at fault, but who knows?

    Anyone here have any ideas?



Viewing 5 replies - 1 through 5 (of 5 total)
  • Cron is a required utility – it also runs in your PHP env.

    Yes, I know – but it should not run on every page access if the DISABLE_WP_CRON constant is set to “true” in the wp-config.php file…

    On my site, wp-includes/cron.php is behaving as though the constant is not set and spawning wp-cron.php when it shouldn’t

    wp-cron.php will not run on every page (load?) (unless you have a funky theme, setup, or plugins) [or poor host env]

    I’m using WordPress 3.4.2 with no changes to the core (except the one I had to make to stop this process from running), with the Genesis Framework and theme. Plugins are a possible culprit, but they’re all very commonly used, nothing unusual.

    I’ll just have to keep researching this until I find the answer.

    You can try adding this to one of your theme files:

    $disable_cron_is = (DISABLE_WP_CRON) ? 'true' : 'false';
    echo "<!-- cron is disabled: " . $disable_cron_is . "-->\n";

    When you load a page and view the source you can tell if it is actually disabled or not, without having to wait for wp-cron.php to be called. Then you can try disabling all of your plugins and see if it switches, then enable them one at a time to find the culprit. If with all of the plugins disabled wp-cron is still enabled, then try switching themes briefly. If none of that works, then maybe there is a typo on your wp-config.php.

    If you still cannot find the cause, while messy you could try this as a workaround for now:

    1) Make a copy of wp-cron.php, name it something like wp-cron-copy.php (original, eh?).

    2) Delete the contents of wp-cron.php so nothing happens when it is called.

    3) Set up a manual cron job that calls wp-cron-copy.php every x minutes (5 is probably sufficient, may even be able to get away with less).

    Note that I have not tested this myself, although unless there are other required references to wp-cron.php it should work.

    Hope this helps.


Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘wp-cron.php Running Despite DISABLE_WP_CRON’ is closed to new replies.