• I am a beginner and need some information. My host has asked me to disable wp-cron because of several instances of excessive usage. The log they provided did show many references to wp-cron over a relatively short period of time – like every couple of minutes. Here is a sample of one of the log entries:

    https://www.xxx.com/wp-cron.php?doing_wp_cron=1490425259.8801419734954833984375″ “WordPress/4.7.3; https://www.xxx.com”
    /etc/httpd/domlogs/xxx.com:67.210.125.160 – – [25/Mar/2017:00:04:09 -0700] “POST /wp-cron.php?doing_wp_cron=1490425449.4664499759674072265625 HTTP/1.1” 200

    I have a site that generally gets less than 250 hits per day. I did the disabling in wp-config by inserting a statement they provided:

    define(‘DISABLE_WP_CRON’. ‘true’);

    However, it appears to me that wp-cron.php must serve a useful purpose.
    1. Will I be missing something important/essential from WP if I have wp-cron disabled? 2. Can I schedule it to run every 6 hours?
    3. If so, how is this done?

    It’s obvious that I don’t know how it works or what it is designed to accomplish… but I think I could learn something from a detailed explanation.

    Thanks in advance,

    Jim

Viewing 6 replies - 1 through 6 (of 6 total)
  • Yes, wp-cron.php does serve a useful purpose. It runs all the tasks scheduled by WordPress itself as well as any plugins you may have that require it. If you disable it via wp-config.php, you should set up a cron job on your web hosting platform to run it regularly. Running it once an hour should reduce the load on your hosting account sufficiently; if you have no tasks that need to run more often, I guess you could do it every 6 hours.

    In the past, disabling wp-cron.php as you’ve done and running it via a cron job was a way to reduce the load on high-traffic accounts, but in the past several years, I have found that it has no longer been necessary because the WordPress developers have done a good job making it efficient.

    How you set up the cron job will depend on your hosting control panel; e.g., cPanel. Your web host will be the best place to get help with that.

    The thing that is bothering me is that it doesn’t make sense that with only 250 hits a day you’re having issues related to wp-cron.php. What you should probably do is take a look at the Codex article on optimizing WordPress. There are steps you can take, like running a caching plugin, that may provide more benefit than disabling wp-cron and running it as a cron job. The other thing to look at is if your hit count is accurate. You don’t mention where you’re getting the 250 number, but some stats programs separate live traffic from bots (automated traffic). If that’s the case, your site may be getting many more hits than that from bots, and blocking the bad bots may be a way to reduce the server load.

    Thread Starter jimf29605

    (@jimf29605)

    Thanks for your response. I guess, though, I need to know if there needs to be any coding at all in wp-cron.php, or is it enough just to trigger it every 6 hours? Currently, it’s an empty file. Does WP populate the file with anything as it needs to? Don’t forget, you are talking to someone who knows nothing about the workings of these files.

    Jim

    Yes, there are 129 lines of code in the wp-cron.php file for WP 4.7.3, and it’s ~3.71 KB. If yours is empty, you should download a fresh copy of WordPress and replace it with an intact file. Why yours would be empty is the next big question. I wonder if that’s something your host did as a short-term measure to decrease the server load? If so, they might have renamed the original file and created a new, empty blank one.

    Ordinarily, you don’t have to alter wp-cron.php at all, just trigger it via your cron job. The command will look something like this, though it will vary depending on how your server is configured:

    
    /usr/local/bin/php -q /home/username/public_html/wp-cron.php >/dev/null 2>&1
    
    Thread Starter jimf29605

    (@jimf29605)

    Thanks for your timely reply. I think we are almost there. I did download and save a fresh copy of wp-cron.php, and it does have 129 lines of code. I then triggered it and got the following msgs:

    <!DOCTYPE html>
    <html xmlns=”https://www.w3.org/1999/xhtml”&gt;
    <head>
    <meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
    <title>Database Error</title>

    </head>
    <body>
    <h1>Error establishing a database connection</h1>
    </body>
    </html>

    –Jim

    Normally, the file wp-cron.php doesn’t have any HTML output whether you trigger it via a cron job, using SSH to run the command above or by browsing to the file, though I have seen the output above with other pages when the database settings in wp-config.php are incorrect or not set.

    Automatic cron is useless and often still a problem in 2017.

    I read everywhere that people disable it with

    define(‘DISABLE_WP_CRON’. true);
    (be careful, define(‘DISABLE_WP_CRON’. ‘true’); IS INCORRECT)

    But at the end, even if you disable it, bots or anybody can run it by visiting this page:
    wp-cron.php

    So is there any solution to stop this script to run totally even if someone visits this page ? yourdomain.com/wp-cron.php

    Thank you.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Disable wp-cron.php?’ is closed to new replies.