Active WordPress sites can have a lot happening in the background. Background activity is controlled by WP-Cron. For improved performance, it’s recommended that WP-Cron be disabled and replaced with a system-level cron process. This makes low-traffic websites run better and significantly reduces the load for high-traffic websites.
Kinsta has a great article explaining how to do that: How to Disable WP-Cron (wp-cron.php) for Faster Performance. The short explanation is to add
define( 'DISABLE_WP_CRON', true ); to your wp-config.php file and then add a real cron job with
crontab. With Kinsta, that real cron job is enabled by default so no extra steps are required.
Also mentioned in the article is that WordPress multisite requires extra steps when enabling system-level cron. Adapted from the described solutions, here is what I’ve been using with Kinsta. Create
#!/bin/bash cd ~/public path=$( pwd ) for url in $( wp site list --field=url --path="$path" --deleted=0 --archived=0 --skip-plugins --skip-themes ); do if [[ $url == "http"* ]]; then wp cron event run --quiet --due-now --url="$url" --path="$path" fi done
crontab -e and add the following to the end of the file. The path will need to adapt to your Kinsta WordPress path.
7,22,37,52 * * * * /www/sitename_123/private/run-wp-cli-cron-for-sites.sh
Save changes to crontab and run
crontab -l to verify the new line was added. That’s it. Now each time
run-wp-cli-cron-for-sites.sh is triggered, it will loop through each site in the multisite and run the cron process.