Dan’s Tech Blog

Domains Guru, Geek, Coder, Lover of Terry’s Chocolate oranges & Pluviophile

Menu
  • Home
  • About Dan
  • Review / Advertise
Menu

How to disable WordPress wp-cron

Posted on October 3, 2010 by admin

[ad name=”postsqrRight”]Recently I have been noticing that this blog has been eating its way through the servers ram like no bodies business, easily using more than 150mb before its automatically killed.

By default the wp-cron.php is run every single time a page is loaded, this includes admin pages. This can lead if you have a busy blog to a lot of cron runs, which simply aren’t needed.

What does the wp-cron do? You might ask, and even if you don’t I will tell you anyway. The wp-cron will do things like scheduled posts and can also include things that plugins want running.

So how we go about this is simple, we will disable the wp-cron from running on every page load, and then add a proper cron job.

First lets disable it:

Simply open wp-config.php and add the follow line.

define(‘DISABLE_WP_CRON’, true);

Note: You need to make sure you use an apostrophe instead of single quotes in the code here, otherwise it will not work!

Second, lets add the cron:

It is probably a good idea to run the cron job every couple of hours, for this we will add something like this.

0      */2      *      *      *

For the command you simply need to call the wp-cron either using wget OR php -q

php -q /home/cPanel_User/public_html/wp-cron.php

OR

wget http://YourDomain.com/wp-cron.php

Personally I’d prefer the php -q option as some hosts can have trouble resolving domains on the same server.

If anyone has any questions or comments please leave a comment below and I’ll try to help. 🙂

[ad name=”posts”]

Facebook Comments

Share this:

  • Click to share on Twitter (Opens in new window)
  • Click to share on Facebook (Opens in new window)

Related

31 thoughts on “How to disable WordPress wp-cron”

  1. Roms says:
    October 25, 2010 at 5:16 pm

    What if i chmod the wp-cron.php to 000? What negativ effect will this have?

    Reply
  2. Dan says:
    October 25, 2010 at 5:24 pm

    Hi, thanks for the comment!

    If you have it set to 000 I believe that means it is only accessible to root, and the owner (after changing permissions) this is likely to cause permissions problems when anything other than root (and perhaps the owner, although I doubt even that) tries to access – read/write to it.

    I’d suggest something like 744 (read by all, write and exec by owner).

    Reply
  3. Scott says:
    November 7, 2010 at 3:19 am

    Thanks for this Dan. Quick question, if we disable wp cron do we HAVE to set up a regular cron? I don’t understand enough about crons to know. What would happen if we disabled wp cron but didn’t set up a cron on our server?

    Thanks

    Reply
    1. Dansgalaxy says:
      November 7, 2010 at 3:26 am

      Hi Scott,

      The WP Cron job runs numerous operations which “need” to be run regularly, this includes scheduled posts, now as we have disabled the cron from running on page load this means scheduled posts won’t be published unless the cron is run an alternative way, as well as this there are other functions which the wp-cron performs and (i think) plug-ins may also run things via cron which they need.

      Easy answer, things might not work as expected or update as expected… So it’s a very good idea to set-up a cron job on the server if you are disabling the on-page-load option for WordPress.

      Hopefully this has answered your questions, Thanks for commenting! 🙂

      Reply
      1. Scott says:
        November 7, 2010 at 4:51 am

        Hi Dan

        Many thanks! Yep, I think I get it now lol. Guess I’ll have to give it a try as I wouldn’t want any of my blogs not functioning properly.

        I’ll come back to your article when I’m ready to disable wp cron. Thanks again!

        Reply
  4. Scott says:
    November 7, 2010 at 3:19 am

    Thanks for this Dan. Quick question, if we disable wp cron do we HAVE to set up a regular cron? I don’t understand enough about crons to know. What would happen if we disabled wp cron but didn’t set up a cron on our server?

    Thanks

    Reply
    1. Dansgalaxy says:
      November 7, 2010 at 3:26 am

      Hi Scott,

      The WP Cron job runs numerous operations which “need” to be run regularly, this includes scheduled posts, now as we have disabled the cron from running on page load this means scheduled posts won’t be published unless the cron is run an alternative way, as well as this there are other functions which the wp-cron performs and (i think) plug-ins may also run things via cron which they need.

      Easy answer, things might not work as expected or update as expected… So it’s a very good idea to set-up a cron job on the server if you are disabling the on-page-load option for WordPress.

      Hopefully this has answered your questions, Thanks for commenting! 🙂

      Reply
      1. Scott says:
        November 7, 2010 at 4:51 am

        Hi Dan

        Many thanks! Yep, I think I get it now lol. Guess I’ll have to give it a try as I wouldn’t want any of my blogs not functioning properly.

        I’ll come back to your article when I’m ready to disable wp cron. Thanks again!

        Reply
  5. Paul Kaser says:
    November 8, 2010 at 6:26 pm

    Thanks, Dan. Our Hostgator shared hosting account kept getting shut down, and I’m pretty sure wp-cron was the issue. I’ve used your tips here to fix things up proper.

    Reply
    1. Dansgalaxy says:
      November 9, 2010 at 11:38 am

      Good to hear! – other than you are using HostGator of course! Ew! (Not a fan of “unlimited” hosts)

      Don’t forget to have a look around some other posts 😉

      Reply
  6. Paul Kaser says:
    November 8, 2010 at 6:26 pm

    Thanks, Dan. Our Hostgator shared hosting account kept getting shut down, and I’m pretty sure wp-cron was the issue. I’ve used your tips here to fix things up proper.

    Reply
    1. Dansgalaxy says:
      November 9, 2010 at 11:38 am

      Good to hear! – other than you are using HostGator of course! Ew! (Not a fan of “unlimited” hosts)

      Don’t forget to have a look around some other posts 😉

      Reply
  7. Andrew says:
    November 15, 2010 at 12:20 am

    There’s nothing wrong with HostGator! In fact, I use them over Linode now for my bigger clients.

    Reply
    1. Dansgalaxy says:
      November 15, 2010 at 12:23 am

      Any host who offers unlimited diskspace and bandwidth is horrible, I am not a fan of lying and false advertising. 🙂

      Reply
  8. Andrew says:
    November 15, 2010 at 12:20 am

    There’s nothing wrong with HostGator! In fact, I use them over Linode now for my bigger clients.

    Reply
    1. Dansgalaxy says:
      November 15, 2010 at 12:23 am

      Any host who offers unlimited diskspace and bandwidth is horrible, I am not a fan of lying and false advertising. 🙂

      Reply
  9. Pingback: wp-cron and MultiSite = Headache | Dan's Tech Blog
  10. Graham says:
    August 9, 2011 at 5:09 am

    Thanks for the article Dan.

    One minor quibble: in the code to add to wp-config.php, you say:
    define(‘DISABLE_WP_CRON’, true);

    Note the quotes should actually be like this: ‘ . I copied and pasted from your article into my wp-config.php, and with the wrong quotes it doesn’t work.

    Thanks, Graham

    Reply
    1. Dansgalaxy says:
      August 21, 2011 at 3:58 am

      Hi Graham, 

      Glad you like the post :)It should be using ‘ quotes, however i think it might be a quirk of WordPress that it changes them as this is something I have run into myself when copying and pasting similar code from blogs! – I’ve added a note to the post to hopefully save confusion in future. :)Dan

      Reply
  11. Jasontoews3434 says:
    September 5, 2011 at 5:36 pm

    Making the change in wp-config.php seems pretty straightforward, but I’m not clear how/where I add the new “every two hours” cron job. Can you give some details on that, or post a relevant link?

    Apologies; this is something new to me.

    Reply
    1. Dansgalaxy says:
      October 10, 2011 at 10:20 pm

      This would be dependant on your webhosting provider, and the control panel they use.

      If they use cPanel it should be fairly straight forward assuming you have permissions to set cronjobs there will be an icon within cPanel called Cron Jobs or similar which you can manage them there. 

      Hope this helps! Thanks for reading.

      Reply
  12. Dean says:
    May 2, 2012 at 10:43 pm

    Hi Dan…been having issues with HG closing one of my reseller accounts down because of usage issues and going to try your tip with the cron. They have disabled my wp-cron on each site on the account which saves me adding the disabled code. My question…I have about 20 sites on this account…do I use the same settings you’ve listed for each site when setting up the manual cron job in cpanel?

    Hope that makes sense? Thanks.

    Dean.

    Reply
    1. Dansgalaxy says:
      May 3, 2012 at 1:57 am

      Assuming each site is a separate wordpress install then yes you’ll need to run the wp-cron.php for each install as (I assume) each will be running different code and connecting to different databases etc to perform their actions. 🙂

      Reply
      1. Dean says:
        May 4, 2012 at 4:01 am

         Hi Dan…as I mentioned in the first comment, HG have disabled my wp-cron from their end which I suppose means I don’t have to add this disable code… define(‘DISABLE_WP_CRON’, true);

        I have set up the cron through my cpanel on one site as you suggest and I get an email every couple of hours when it runs. This is the message I get:

        Cron php -q /home/cPanel_User/public_html/wp-cron.php…No input file specified.

        Does this sound right? Is this because the wp-cron has been disabled? Sorry, just wondering if it looks right. Appreciate your help. Thanks.

        Dean.

        Reply
        1. Dansgalaxy says:
          May 4, 2012 at 4:32 am

          It depends *how* HostGator in their wisdom has disabled wp-cron.php, it might be they have disallowed the wp-cron.php file from executing. Check your wp-config.php to see if the disable_wp_cron line has been added, if it’s not there chances are they disabled it by changing the file permissions on the wp-cron.php file or simply deleting the file.

          Reply
          1. Dean says:
            May 9, 2012 at 3:43 am

             Ok..thanks. No, they have changed the file permissions. Do I still need to add the line of code?
            Appreciate the time you have taken to answer my questions.

          2. Dansgalaxy says:
            May 10, 2012 at 7:14 pm

            I’d add it just to be sure, but you should ask how they disabled the cron as need to ensure you won’t run into issues due to whatever they have imposed. 

  13. Jddean73 says:
    May 24, 2012 at 1:10 am

    Hi Dan,

    Thanks for this information. Just to clarify. In this command:
     php -q /home/cPanel_User/public_html/wp-cron.php

    cPanel_User is replaced by the username of the database, correct?

    Just checking. Thanks.

    JD.

    Reply
    1. Dansgalaxy says:
      May 24, 2012 at 2:17 am

      It’s the cPanel username, not the database username. Although in most cPanel installs the cpanel username prefixes the db name. Eg. if it’s called dan_wordpress the cPanel username is probably “dan” 

      Reply
  14. Rob Thrasher says:
    February 9, 2013 at 1:53 pm

    OK, so I never really paid attention to Updates or Update scheduling. why do I need to add code to the tab to poll every 60 minutes when right below Updates, there is a field that allows me to select to poll every so many minutes? I think my blogs get shut down every time the spiders come to crawl because they trigger updates, maybe???   What am I missing here? 🙂

    Reply
  15. ccmedia says:
    October 3, 2013 at 9:10 am

    You say to add this line to the wp-config file but other articles say to add it to the top line of wp-cron itself? Does it make a difference

    Reply

Leave a Reply to SARAteah Cancel reply

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

Recent Posts

  • Can technology help predict outcomes?
  • Review: UnoDNS from UnoTelly.com
  • HungryHouse goes Mobile!
  • CAD Helps US Army with Star Trek-Style Replicators
  • Online Reputation Management: An Increasingly Needed Industry

Recent Comments

  • umeh on How to: Install FireSheep
  • ali on How to: Install FireSheep
  • Dan on HungryHouse goes Mobile!
  • Oliver on HungryHouse goes Mobile!
  • ForsterDJ on HungryHouse goes Mobile!

Categories

  • Cool Sites
  • Cool Tech
  • General stuff
  • Google
  • How Tos & Tutorials
  • Humor and funny crap!
  • Infographics
  • Microsoft
  • Ponderings
  • Projects
  • Ranting
  • Reviews
  • Scripts
  • Sponsored Posts
  • Student Partner
  • Tech Events
  • Technological Ponderings
  • Top Ten…
  • Tv/Video/Music Talk
  • Twitter
  • Uncategorized
  • University
  • vLogs
  • Web Hosting
  • Windows Phone
  • Windows Stuff
  • XBOX 360
  • YouTube

Archives

  • April 2015
  • October 2014
  • October 2013
  • February 2013
  • December 2012
  • November 2012
  • October 2012
  • August 2012
  • June 2012
  • May 2012
  • April 2012
  • March 2012
  • February 2012
  • January 2012
  • December 2011
  • November 2011
  • October 2011
  • September 2011
  • August 2011
  • July 2011
  • June 2011
  • May 2011
  • April 2011
  • March 2011
  • February 2011
  • January 2011
  • December 2010
  • November 2010
  • October 2010
  • September 2010
  • August 2010
  • July 2010
  • March 2010
  • February 2010
  • December 2009
  • November 2009
  • October 2009
  • September 2009
  • July 2009
  • June 2009
  • May 2009
  • April 2009
  • March 2009
  • February 2009
  • January 2009
  • December 2008
  • November 2008
  • September 2008
  • August 2008
  • July 2008
  • June 2008
  • May 2008
  • April 2008
  • March 2008
  • February 2008
  • January 2008
  • December 2007
  • November 2007
  • October 2007
  • September 2007

Meta

  • Log in
  • Entries RSS
  • Comments RSS
  • WordPress.org
Proudly Hosted by allthe.domains
©2019 Dan’s Tech Blog | Built using WordPress and Responsive Blogily theme by Superb