Disable wp-cron, and run linux cron instead in multisite environment

I have a multi-site environment with domain mapping.

I tried to use these two examples to make Linux cron work instead of wp-cron:

Read More
  1. https://www.lucasrolff.com/wordpress/why-wp-cron-sucks/
  2. https://tigr.net/3203/2014/09/13/getting-wordpress-cron-work-in-multisite-environment/

Then, I set the cron in the cPanel and all looks great, but I started getting emails containing errors from the cron job:

PHP Warning:  include_once(/my-cont/sunrise.php) [<a href='function.include-once'>function.include-once</a>]: failed to open stream: No such file or directory in /home/user/public_html/wp-includes/ms-settings.php on line 18
PHP Warning:  include_once() [<a href='function.include'>function.include</a>]: Failed opening '/my-cont/sunrise.php' for inclusion (include_path='.:/usr/local/php53/pear') in /home/user/public_html/wp-includes/ms-settings.php on line 18
PHP Notice:  Undefined index: HTTP_HOST in /home/user/public_html/wp-includes/ms-settings.php on line 30

To remove the “HTTP_HOST” notice, I have added to the PHP file: $_SERVER['HTTP_HOST'] = 'mydomain.com';

my-cont is my content directory’s new name. I have changed wp-config.php to reflect this:

define( 'WP_CONTENT_DIR', $_SERVER['DOCUMENT_ROOT'] . '/my-cont' );
define( 'WP_CONTENT_URL', 'http://'.$_SERVER['HTTP_HOST'].'/my-cont');

Any ideas?

Related posts

Leave a Reply

1 comment

  1. I also have linux cron jobs running in a WordPress multisite environment and was getting the same error of HTTP_HOST.

    My cron scripts load wp-load.php to gain access to WordPress core functions. When on a single site, they work fine, switch to multisite, I received the errors.

    I tried the simplest and the obvious first before committing to a full debug of the WP core.

    In each of my cron script I added,

     define('DOING_CRON', true);
     if (!isset($_SERVER['HTTP_HOST'])) {
          $_SERVER['HTTP_HOST'] = 'domain.com';  // replace with primary host
     }
    
     // then load wordpress
     require 'wp-load.php';
    

    This action was sufficient, and my linux cron scripts resume without further incident