How To Stop WP-CRON.php From Using To Much CPU Usage

Three days ago arvixe telling my site using to much their cpu usage. They complaint about wp-cron.php and index.php process which I believe it was looping and won’t stop in background. wp-cron is just like cron job in normal condition. The crazy thing everyone doesn’t know is, it’s loading each time visitors coming to their site. I don’t know why wordpress don’t fix it or at least give options to run it each time frame.

For a site using wordpress and have a lot articles/pages the optimization for it is just disable wp-cron, another option is disable wp-cron and running cron job from cpanel which can be setup in time frame.

You will lose schedulle post feature but it’s better than get suspended right? You still can run cron in time frame you setup from cron job panel than using crazy method like spawn it each time visitors coming to your site. Let’s do this thing, it’s very easy…

[to_plus]

  1. Open your wp-config.php and put this after the <?php. define(‘DISABLE_WP_CRON’, true);
  2. Open wp-includes folder and find a file with name cron.php
  3. Find string “function wp_cron() {
  4. Replace all function with code below :
    function wp_cron()
    {// Prevent infinite loops caused by lack of wp-cron.php
    if ( strpos($_SERVER[‘REQUEST_URI’], ‘/wp-cron.php’) !== false || ( defined(‘DISABLE_WP_CRON’) && DISABLE_WP_CRON ) )
    return;if ( false === $crons = _get_cron_array() )
    return;$local_time = time();
    $keys = array_keys( $crons );
    if ( isset($keys[0]) && $keys[0] > $local_time )
    return;$schedules = wp_get_schedules();
    foreach ( $crons as $timestamp => $cronhooks ) {
    if ( $timestamp > $local_time ) break;
    foreach ( (array) $cronhooks as $hook => $args ) {
    if ( isset($schedules[$hook][‘callback’]) && !call_user_func( $schedules[$hook][‘callback’] ) )
    continue;
    // spawn_cron( $local_time );
    break 2;
    }
    }
    }
  5. Save it/replace cron.php file with the new edited cron.php
  6. Done

After doing this your wp-cron has been disabled and never ever run each time a visitors coming to your site. But you will lose schedulle post, to fix this problem open your hosting control panel and set cron job from there to run your wp-cron.php. You can set it run each 24 hours or in time frame you need.

After doing this small optimization arvixe not complaint to me. It’s mean this is maybe the big issue for worpdress to update their cron setting.

That’s a share for today, have a great day everyone, and Happy New Year! 😀

 

Similar Posts:

6 thoughts on “How To Stop WP-CRON.php From Using To Much CPU Usage”

  1. Howdy! This is kind of off topic but I need some guidance from an established blog. Is it tough to set up your own blog? I’m not very techincal but I can figure things out pretty quick. I’m thinking about setting up my own but I’m not sure where to begin. Do you have any ideas or suggestions? With thanks

  2. Hello,

    Does it mean if i don’t need schedule post i can edit following your guide without any problems? Because wp-cron of my site running too much, i want to turn it off.

    Thank you.

  3. I know this if off topic but I’m looking into starting my own blog and was wondering what all is required to get setup? I’m assuming having
    a blog like yours would cost a pretty penny? I’m not very web smart so I’m not 100% sure.

    Any recommendations or advice would be greatly appreciated.
    Appreciate it

  4. It’s hard to come by knowledgeable people about this topic, but you sound
    like you know what you’re talking about! Thanks

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.