Add an external cron-job: SiteGround

If you are using SiteGround, the best way to set up a cron job is through the SiteGround cron manager.

Create an external cron job on SiteGround

Go to the account you want to manage in SiteGround and click on Site Tools.

Once in the Site Tools click on DEVS in the left-hand menu.

With the DEVS menu open click on Cron Jobs.

Find the Cron Job form.

Enter the following values into the Command setting and replace your-domain.com with the URL of your actual site.

php /home/customer/www/your-domain.com/public_html/gh-cron.php /dev/null 2>&1

Enter the following into the setting with Minute Hour Day Month Weekday

* * * * *

And the click create.

AWS Integration

If you have the  AWS SES integration installed you will have to create an additional cron job for it as well.

Enter the following values into the Command setting and replace  your-domain.com with the URL of your actual site.

php /home/customer/www/your-domain.com/public_html/aws-cron.php /dev/null 2>&1

Enter the following into the setting with Minute Hour Day Month Weekday

* * * * *

And the click create.

For Network/Multisite Installs

If you have a multisite installation, the setup is a bit trickier and requires some extra files.

In the root /public_html/ folder in your account, add the following PHP file gh-ms-cron.php.

Copy the following contents into the file.

<?php
/**
 * This file can be used to process the event queue directly without the overhead of other WordPress tasks.
 * Call this file directly from a sever Cron
 *
 * @package WordPress
 */

ignore_user_abort( true );

/* Don't make the request block till we finish, if possible. */
if ( function_exists( 'fastcgi_finish_request' ) && version_compare( phpversion(), '7.0.16', '>=' ) ) {
   if ( ! headers_sent() ) {
      header( 'Expires: Wed, 11 Jan 1984 05:00:00 GMT' );
      header( 'Cache-Control: no-cache, must-revalidate, max-age=0' );
   }

   fastcgi_finish_request();
}

if ( ! empty( $_POST ) || defined( 'DOING_AJAX' ) || defined( 'DOING_CRON' ) || defined( 'DOING_GH_CRON' ) ) {
   die();
}

/**
 * Optional password lock to avoid expensive DDOS attacks
 */
# define( 'GH_CRON_PASS', 'your_password' );
#
# if ( $_GET[ 'pass' ] !== GH_CRON_PASS ){
#    die();
# }

/**
 * Tell WordPress we are doing the CRON task.
 *
 * Keep for compatibility
 *
 * @var bool
 */
define( 'DOING_CRON', true );

/**
 * Special const for Groundhogg compat
 *
 * @var bool
 */
define( 'DOING_GH_CRON', true );

/**
 * The number of concurrent requests to make.
 */
define( 'GH_MS_CRON_CONCURRENCY', 5 );

if ( ! defined( 'ABSPATH' ) ) {
   /** Set up WordPress environment */
   require_once( __DIR__ . '/wp-load.php' );
}

// Check if Groundhogg is active...
if ( ! defined( 'GROUNDHOGG_VERSION' ) || ! is_multisite() ) {
   die();
}

$requests = [];

/**
 * Build a multi request object (faster and better performance + callbacks) for each sub site
 *
 * @var $blog WP_Site
 */
foreach ( get_sites() as $blog ) {

   $request = [
      'type'     => 'GET',
      'url'      => $blog->siteurl . '/gh-cron.php',
   ];

   $requests[] = $request;
}

while ( ! empty( $requests ) ){
   Requests::request_multiple( array_splice( $requests, 0, GH_MS_CRON_CONCURRENCY ) );
}

die();

As above, create a new cron job with the following details, replacing your-domain.com with the base URL of your network.

php /home/customer/www/your-domain.com/public_html/gh-ms-cron.php /dev/null 2>&1

Enter the following into the setting with Minute Hour Day Month Weekday

* * * * *
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us