How to setup server-side cron for a WordPress Multisite

When WordPress is setup as a Multisite/network installation, the cron event process needs to be called for each individual site in the network. This can either be manually setup or solved using a simple script. The script below was originally created by Bjørn Johansen.

Alternatively server-side cron can easily be setup with the latest version of Servebolt Optimizer. Simply login to your site with SSH and run these two commands:

  1. cd ~/public/
  2. wp servebolt cron enable

Time needed: 10 minutes.

Setup server-side cron for WordPress Multisite

  1. Disable WP-cron in WordPress

    Disable the built-in WP-cron process by editing wp-config.php and add (or uncomment if it already exists) this line:

    define( 'DISABLE_WP_CRON', true );

    Save and close the file.

  2. Create a script for WP Multisite

    Create a new file named and add the following:

    # Copyright © 2015 Bjørn Johansen
    # This work is free. You can redistribute it and/or modify it under the
    # terms of the Do What The Fuck You Want To Public License, Version 2,
    # as published by Sam Hocevar. See for more details.


    # Check if WP-CLI is available
    if ! hash wp 2>/dev/null; then
    echo "WP-CLI is not available"

    # If WordPress isn’t installed here, we bail
    if ! $(wp core is-installed --path="$WP_PATH" --quiet); then
    echo "WordPress is not installed here: ${WP_PATH}"

    # Get a list of site URLs
    if $(wp core is-installed --path="$WP_PATH" --quiet --network);
    SITE_URLS=`wp site list --fields=url --archived=0 --deleted=0 --format=csv --path="$WP_PATH" | sed 1d`
    SITE_URLS=(`wp option get siteurl --path="$WP_PATH"`)

    # Loop through all the sites
    for SITE_URL in $SITE_URLS

    # Run all event hooks that are due
    for EVENT_HOOK in $(wp cron event list --format=csv --fields=hook,next_run_relative --url="$SITE_URL" --path="$WP_PATH" | grep now$ | awk -F ',' '{print $1}')
    wp cron event run "$EVENT_HOOK" --url="$SITE_URL" --path="$WP_PATH" --quiet


    Save and close the file.

  3. Make the script executable

    Run this command to make the script executable:

    chmod +x

    You can also test the script like this:


  4. Setup the cron job in our Control Panel

    Go to your WordPress site cron settings page in our Control Panel and enter the following in the time field:

    */30 * * * *

    This will make the cron job run once every 30 minutes. You can set it to be more frequent, but note that larger WordPress Multisite installations may require some time for all cron processes to complete.

    In the command field, enter the following:

    sh /kunder/group/user/public/

    Replace the path with the full path to your WordPress site installation. You can find the full path in the site settings in your Servebolt Control Panel.

  5. Optionally, turn off email notifications

    If you don’t need an email notifications for when cron jobs have been executed, you can select the–newly created–cron job in the list of this page and select “Do not send email” in the drop-down box below. Click the “Update” bottom on the bottom of the page.

Note: if you still receive emails regarding cron jobs even after silencing them, then there’s something wrong with one/more cron events. To get rid of these email, solve the actual error with the cron events.

Give us your feedback on this article