WordPress.org

Ready to get started?Download WordPress

Forums

wp-cron.php Running Despite DISABLE_WP_CRON (6 posts)

  1. zenologue
    Member
    Posted 1 year ago #

    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?

    Thanks

    Nigel

  2. Pioneer Valley Web Design
    Member
    Posted 1 year ago #

    Cron is a required utility - it also runs in your PHP env.

  3. zenologue
    Member
    Posted 1 year ago #

    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

  4. Pioneer Valley Web Design
    Member
    Posted 1 year ago #

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

  5. zenologue
    Member
    Posted 1 year ago #

    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.

  6. mvandemar
    Member
    Posted 1 year ago #

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


    <?php
    $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.

    -Michael

Topic Closed

This topic has been closed to new replies.

About this Topic