Wp-Cron.php May Be Slowing Your Site - Create A Server Cronjob Instead | WP Learning Lab

Поділитися
Вставка
  • Опубліковано 23 січ 2017
  • Grab Your Free 17-Point WordPress Pre-Launch PDF Checklist: wplearninglab.com/17-point-wp...
    These are two pieces of code referenced in the video:
    define('DISABLE_WP_CRON', 'true');
    cd /home/HOSTING_USERNAME/public_html; php -q wp-cron.php
    When you create your cronjob make sure you replace HOSTING_USERNAME with the username of your hosting account. To find it see the section below called "Finding Hosting Username".
    --------
    Wp-Cron.php May Be Slowing Your Site - Create A Server Cronjob Instead
    If your site gets a lot of traffic there is a good chance that the wp-cron cronjob is slowing down your site. The wp-cron.php runs every time a page loads on your site. It's checking to see if the site has any scheduled posts that need to be published. This is fine when a website has low traffic, but when traffic is higher it can become a big problem. Here's how to create a server-side cronjob to fix the problem.
    An interesting tidbit is that if you schedule your posts they won't publish if no-one visits your site. Or they will publish later than you want because people come to your site after the scheduled publishing time.
    You might be wonder what is cron job. At it's simplest, it is a script that runs at set times and causes other scripts to run. Like a WordPress scheduled post, for example.
    Let's get to it.
    There are two things we need to do to move our cron jobs server-side.
    First we have disable the wp-cron.php file so it's cronjob stops.
    Then we need create a cron job on the server.
    To disable wp-cron.php you need to open your wp-config.php file for editing.
    Inside that file, just below where you have all your database information, paste the following code on it's own line.
    define('DISABLE_WP_CRON', 'true');
    That will disable the wp cron. Save the wp config file and step one is complete.
    Next, Finding Hosting Username.
    To find this open the file manager in your cPanel and look for where it says /home/ at the top of the file hierarchy on the left side.
    Right after /home/ is your hosting user name. Make note of it because we'll need it soon.
    Now, back in your cPanel find an option called Cron Jobs and open it.
    On the following page you will see a section called Add New Cron Job. There you will be able to set the Minute, Hour, Day, Month and Weekday of your cron job.
    At the bottom of that list you will see an input field called Command. Paste the following code into it, replacing "HOSTING_USERNAME" with your actual username:
    cd /home/HOSTING_USERNAME/public_html; php -q wp-cron.php
    For the timing options you can choose whatever you wish. I tend to stick with running the cron every 6 hours. To do that choose the following:
    Minute - 0 (at the beginning of every hour)
    Hour - every 6th hour
    Day - every day
    Month - every month
    Weekday - every day
    That will run the cron job every 6 hours on the hour for eternity or at least until you turn it off.
    Then click the Add New Cron Job button and you're done. You've created your first cron job.
    Your server and your host will be thanking you when your site traffic picks up!
    I hope this information helps you! If you have any questions leave a comment below or ping me @WPLearningLab on Twitter.
    --------------
    If you want more excellent WordPress information check out our website where we post WordPress tutorials daily.
    wplearninglab.com/
    Connect with us:
    WP Learning Lab Channel: ua-cam.com/users/subscription_c...
    Facebook: / wplearninglab
    Twitter: / wplearninglab
    Google Plus: google.com/+Wplearninglab
    Pinterest: / wplearninglab

КОМЕНТАРІ • 48

  • @wplearninglab
    @wplearninglab  7 років тому

    I've created a playlist full of useful WordPress admin tweaks. If you want to level-up your admin dashboard check out the playlist here: ua-cam.com/video/YhKVXC8t6DA/v-deo.html

    • @obertscloud
      @obertscloud 3 роки тому

      thanks i have 40 sites on my shared hosting only 4 of them have big traffic.. but i want to set this for all hostgator recommends i take 60 div by 40 i get 1.5 so then in minutes start with 0 then the next one is 1.5 the next , etc so they are not all firing the same time, is this right ?

  • @stuartdaniells5204
    @stuartdaniells5204 4 роки тому

    So pinpoint accurate and clear cut, Thank a ton once again Bjorn. And wish you a happy and prosperous new year!

  • @anainmazatlan
    @anainmazatlan 5 років тому +4

    Thank you so much for this video! My sites kept being shut down because one of them kept going over the CPU usage. One of the suggested fixes was to add a CRON JOB and I had NO idea what they were talking about. This clears it up very nicely and I now feel confident to go ahead and make the changes.

  • @nonfictionchris4821
    @nonfictionchris4821 5 років тому +1

    Crystal clear as always. Thanks Bjorn!

    • @wplearninglab
      @wplearninglab  5 років тому +1

      You're welcome Christopher, thanks for watching!

  • @adv.rameshraghav2803
    @adv.rameshraghav2803 5 років тому

    Thank you very much for the video. You are an amazing teacher.

  • @SoundsFromSound
    @SoundsFromSound 7 років тому +1

    Excellent video on Cron! Thank you for this!

    • @wplearninglab
      @wplearninglab  7 років тому

      +SoundsFromSound You're welcome, thanks for watching!

  • @eze8172
    @eze8172 6 років тому +1

    WOW, thanks bro for this info.. it really helped me.

  • @worldofnissanka9222
    @worldofnissanka9222 3 роки тому

    Thank you very much... its really useful information.... Thank you again sharing knowledge

  • @Cube855
    @Cube855 7 років тому +1

    Thank you :)

    • @wplearninglab
      @wplearninglab  7 років тому

      +vichet mut You're welcome Vichet, thanks for watching!

  • @sobirmalilov8838
    @sobirmalilov8838 2 роки тому

    Thanks bro :)

    • @wplearninglab
      @wplearninglab  2 роки тому +1

      No problem, I'm happy you found it useful. Thanks for watching!

  • @kashifhussnain7456
    @kashifhussnain7456 3 роки тому

    i have cron system problem after install wp rocket plugin, my site is getting low traffic how can i fix this? same way you told in this video or any different way

  • @thefluffyunicorn5967
    @thefluffyunicorn5967 7 років тому +1

    Im definately going to get around to getting this done very soon I have a cron job for Amazon associates to keep products updated. I have a question I hope you dont mind my websitie had been under construction I had to start over as of right now Im getting little to no traffic right this minute theres not much content at all. So what my long question is ever since I applied a cron job my websitie at time gets overloaded where I get server errors the memory usage bar at times not all the time will go from red to green. In your opionion do you believe my websitie at times can become overloaded from the cron job?

    • @wplearninglab
      @wplearninglab  7 років тому +1

      +Brittany Quinn Since you have little content at the moment I don't think a cron job is causing the overload problem. Unless the cron job is running every minute. It could be caused by plugins that use a lot of server resources like Wordfence.
      If you contact your host's
      support they'll be able to pull up the server logs and possibly tell you what's causing the problem.
      I hope that helps and thanks for watching!

  • @lucab3036
    @lucab3036 2 роки тому

    Hi, (newbie question) I have a Theme that works with cron.php, if I make this procedure and activate Cron Job is possible that my Theme don't work? Or Cron.php and Cron Job are the same?

  • @shortclear9675
    @shortclear9675 3 роки тому

    Disabling the Wp Cron job and Adding real time Cron job decreases the Adsense Revenue ?. My Analytics views and Adsense Views are mismatching, adsense showing nearly half views of what analytics showing. reply me to solve this issue.

  • @gabbycanario7506
    @gabbycanario7506 4 роки тому

    weird. I don't have cron jobs. maybe it was moved with an update?

  • @ashishchaudhary2276
    @ashishchaudhary2276 4 роки тому +1

    Sir I have done as you mention in video and now my Updraft is showing this error "Warning: WordPress has a number (18) of scheduled tasks which are overdue. Unless this is a development site, this probably means that the scheduler in your WordPress install is not working. Read this page for a guide to possible causes and how to fix it."

    • @wplearninglab
      @wplearninglab  4 роки тому +1

      Hi Ashish,
      You're definitely commenting on the correct video. Updraft schedules (and any other schedules) require wp-cron to run. The wp-cron is triggered when someone visits your site. If you don't have any visitors around the time the scheduled task needs to run then it won't run.
      Using the technique in this video should do the trick. Or you can set up a free uptime monitor that "pings" or visits your site every 5 minutes to make sure it's still online. That visit will trigger the wp-cron file.
      I hope that helps :) Let me know if you have any further questions. Thanks for watching!

  • @arturo5050
    @arturo5050 Рік тому

    What happend if we only use it for woocomerce and not for blog?

  • @AdmicheWorldPicture
    @AdmicheWorldPicture 3 роки тому

    Hi get some problems to configure the cron can you help me

  • @bertzomer3999
    @bertzomer3999 5 років тому +1

    Thanks for sharing, Bjorn, Hostpapa are on my case about setting up cron job I have done what you have recommend problem is now my website is so slow any ideas?

    • @wplearninglab
      @wplearninglab  5 років тому

      Hey Bert,
      And when you turn the Cron job off, your site is immediately faster.

    • @bertzomer3999
      @bertzomer3999 5 років тому

      @@wplearninglab Yes but Hostpapa have also said my site is interfering with others I may need to change my theme I did a speed check My site gets a mark 7 out of 100 I have never seen my site this slow ever I am thinking of leaving Hostpapa but I don't know where to go from here either, Maybe you would have some idea plus to find a server that can handle .com.au TLD's I am dam sure I don't want to go back to Godaddy..

  • @deminmax
    @deminmax 6 років тому

    Will it break any of my plugins?
    Do I understand it correctly that every plugin or wordpress itself when the cron is needed writes to wp-cron.php? And then when somebody visits your site, wordpress checks the file and executes commands? When we change to the server cron, we execute all the same commands from this file, just on the time basis? So plugins and everything else runs in the same way?

    • @wplearninglab
      @wplearninglab  6 років тому

      What you described is correct. All we're doing is having the cron run on a schedule that we set instead of running when someone visits the site. It should not affect the functioning of your plugins unless a particular plugin needs to run when someone visits instead of on a different schedule. But I can't think of any that would do that.

    • @deminmax
      @deminmax 6 років тому

      What's the difference between your way and curl or wget ways of doing it?

  • @worldofnissanka9222
    @worldofnissanka9222 2 роки тому

    is this method for cyber panel?

  • @gtaagent
    @gtaagent 6 років тому

    Great video, however I have done everything verbatim and it's not working. Any suggestions? Thanks

    • @wplearninglab
      @wplearninglab  6 років тому

      Hi Paul,
      Do you know what part isn't working? The disabling of the wp-cron.php file or the execution of the server-side cron?

    • @aqualife8227
      @aqualife8227 6 років тому

      The server side executing the cron.

  • @EmilyRose0
    @EmilyRose0 4 роки тому

    If you make a vid about defines you should know what you are talking about. It should be true without quotes! I checked some source files and there was no strict type check so any string that is not empty should work based on that you could define it as 'i_am_stupid' and it will work as that also evaluates to true. So not sure why there is a comment about it not working without quotes below, maybe a plugin/host thing or I missed something. *However* you should be teaching it right to people and make them put a proper boolean value in there!

  • @frederickjohnh
    @frederickjohnh 3 роки тому

    Sorry the logic in this video regarding scheduling content is faulty. If you have things setup the default way and a article set to publish at 8:00 and no one visits the site until 9:05 it will get published and they will see it. If you schedule the cron job to only run every six hours, it would then run at 6 am , noon, 6 pm, and midnight. These means that the article set to publish at at 8:00 will not get published until noon at the next cron run no mater how many people visit the site. If you are scheduling content then you should have your cron run more often or at least the content creator should know the schedule.

  • @maurice9660
    @maurice9660 6 років тому +1

    Thumbs down, video is not in German.

    • @wplearninglab
      @wplearninglab  6 років тому

      lol, thanks Maurice. But nowhere does it say the video would be in German. I speak German fluently, so I could make videos in German. I just don't think the demand is big enough.

    • @maurice9660
      @maurice9660 6 років тому

      I just trolled lol the video helped me a lot.