Run WP Cron on Multisite

If you are already using WP Rocket, you are probably advised to disable wp’s default Cron and run it at the server level.

For normal websites, just follow the plugin’s instructions. However, wp multisite has to change a bit. Here is the author’s method Slavi Marinov , works on WP-CLI. Let’s proceed, right?

Disable WP Cron by default

Openwp-config.php add the following code if not already

define('DISABLE_WP_CRON', true);

Install Multisite Cron

Create filemulti_cron.php in the root directory with the content:

if (!isset($_REQUEST['go'])) {
    if (php_sapi_name() != "cli") {

// We want to see all errors
ini_set('display_errors', 1);
header( 'Content-type: text/plain; charset=utf-8' );
set_time_limit(30 * 60);
$php_cmd = 'php';
$php_cli_options = array(
foreach ($php_cli_options as $php_bin_opt) {
    if (@is_file($php_bin)) {
        $php_cmd = $php_bin_opt;
$wp_cli_options = array(
$wp_cmd = $wp_cli_options[0];
foreach ($wp_cli_options as $wp_cli_option) {
    if (@is_file($wp_cli_option)) {
        $wp_cmd = $wp_cli_option;
if (preg_match('#win#si', PHP_OS)) { // on windows we call wp directly
    $main_cmd = $wp_cmd;
} else {
    $main_cmd = "$php_cmd $wp_cmd";
$cmd = "$main_cmd site list --field=url --archived=0 --deleted=0 --skip-packages --skip-plugins --skip-themes --format=json";
$json_str = trim(`$cmd`);
$blogs = empty($json_str) ? array() : json_decode($json_str, true);
$blogs = empty($blogs) ? array() : $blogs;
$total = count($blogs);
echo "<pre>";
echo "Starting at " . date('r') . "\n";
foreach ($blogs as $idx => $url) {
    $cur = $idx + 1;
    echo "$cur of $total) Processing: [$url]\n";
    $url_esc = escapeshellarg($url);
    $cmd = "$main_cmd cron event run --due-now --url=$url_esc";
    $cmd_res = trim(`$cmd`);
    echo "cron: [$cmd_res]\n";
    echo "\n<br/>";
    // Output stuff every X few showers
    if ($idx % 5 == 0) {
echo "Finished at " . date('r') . "\n";
echo "</pre>";

Set up Cron jobs on the server

ssh go to the server and run the command:

crontab -e


*/15 * * * * wget -q -O - &>/dev/null 2>&1

Note: Using your network’s primary domain name, 15 is the number of minutes the cron takes – this can be set up for you.

To save, press Ctrl + X, y and Enter . Don’t forget to restart nginx.

We will be happy to hear your thoughts

Leave a reply

Generic filters
Exact matches only
Register New Account
Reset Password
Shopping cart