an
groups-icon

How to Replace WordPress Cron with a Real Cron Job with WordPress

Wait a minute... This content is very very old. We no longer sell or support this theme version. New Topics
  • Version 9
    Stephen Proffitt
    0 points
    Beginner

    If your system is maxing out memory running CP a possible cause is the wp cron. This little tidbit will help relieve the stress on your server resources. We recently switched to this method here and now all is well.

    How to Replace WordPress Cron with a Real Cron Job

    Have you ever noticed that your scheduled posts in WordPress are missing? Though WordPress has its own cron feature that dictates the scheduling of your blog’s posts and events, WP-cron is not a literal cron job.

    Real Cron Job vs. WP-Cron

    Real cron jobs can be controlled by the user, making certain that the items constrained by schedule are run appropriately. Also, for a high-traffic WordPress site, a real cron job can assist with reducing the chances of downtime by lowering the bandwidth on the server, thus using less server resources.

    WP-cron is a virtual cron that only works when the page is loaded. WP-cron is first loaded by WordPress when a page is requested on the front or backend of a site at which point WP-cron displays the necessary page to the site visitor. Though convenient, it is known to fail for a variety of reasons, including but not limited to the following:

    Conflict of plugins
    DNS-related issues
    WordPress bugs
    Use of caching plugins
    Large server load

    Replace WP-Cron with a Real Cron Job

    The best way optimize the efficiency of your WordPress cron jobs is to disable WP-cron and set up a normal cron job through cPanel which will run every hour.

    1. Disable wp-cron.php

    You can disable WP-cron by modifying the wp-config.php (located in the folder where WordPress is installed). Open the wp-config.php file and add the following line to the top of the page:
    define(‘DISABLE_WP_CRON’, true);

    2. Set Up a Real Cron
    Warning: It is important that you familiarize yourself with how cron jobs work. You need to have a working knowledge of Linux commands before you can use cron jobs effectively.

    To set up a real cron job:

    Log into your cPanel.
    In the Advanced section, click Cron jobs.
    Under Add New Cron Job, select the time interval. HostGator recommends that you do not set
    the interval lower than 15 minutes.

    Set the cron command to the following, replacing yourwebsite.com with your actual domain name:
    wget -q -O – https://yourwebsite.com/wp-cron.php?doing_wp_cron >/dev/null 2>&1
    The above command tells the Linux server to run wp-cron via wget, which will trigger the
    wp-cron.php script to do it’s job on your schedule instead of on each page view. This will lessen
    the amount of processes on the server.

    Click Add New Cron Job to set the cron.

    In order to test out the new cron, simply wait for the elapsed time period for the cron to run. In the event that the cron does not run, please review the steps listed above to ensure that you have completed all steps correctly.

    August 9, 2014 at 7:46 pm
  • Mark Fail
    11,847 points
    Platinum User
    Bronze User Silver User Gold User Platinum User Helpful Award Fast Responder Thank You Coffee Villian Award Video Testimonial
    Members Only Content

    This reply is for PremiumPress customers only.

    Login Now
    August 10, 2014 at 3:43 am
  • Malgorzata Szalata
    0 points
    Beginner
    Members Only Content

    This reply is for PremiumPress customers only.

    Login Now
    August 10, 2014 at 5:03 am
  • 0 points
    Beginner
    Members Only Content

    This reply is for PremiumPress customers only.

    Login Now
    August 10, 2014 at 8:56 am
  • Stephen Proffitt
    0 points
    Beginner
    Members Only Content

    This reply is for PremiumPress customers only.

    Login Now
    August 10, 2014 at 3:56 pm

411

Views

4

Replies