Sometimes you will run into issues on your child sites which are being caused by active cron jobs. Cron jobs are recurring tasks that need to be run on a site. Most of the time, cron jobs are created by the active plugins (e.g., these cron events all running due to WooCommerce):
woocommerce_cancel_unpaid_orders woocommerce_cleanup_sessions woocommerce_cleanup_personal_data woocommerce_cleanup_logs woocommerce_scheduled_sales woocommerce_geoip_updater delete_expired_transients delete_version_transients
Cron Events
There are ways to view all cron jobs on a child site by using a plugin like WP Crontrol.
In this post, we are going to use the many options that WP-CLI has related to cron jobs. There may be extreme cases, where you would not be able to load wp-admin on a child site to install a plugin, then see from the UI which cron events are running. But if you have sFTP/SSH access and WP-CLI is already installed, you have a clear way to find out what is going on with active cron jobs running.
Here is a list of all scheduled cron events on a site you can run;
wp cron event list
To delete a specific cron event:
wp cron event delete delete_version_transients
To test if WP Cron is working correctly on a site:
wp cron test
To delete all cron events from the options database:
wp option delete cron
Cron jobs would be added back into the option value after that value is wiped out. If you only did have MySQL or phpMyAdmin access on a site, you can run this query:
SELECT * FROM `wp_options` WHERE option_name = 'cron'
It is very useful to find out what cron events are running on a site and to be able to delete them. For example, an active plugin is causing issues with thousands of cron events being run on a site, which ends up killing the site’s performance.
All of the common cron event related commands are in this Gist.
WP Cron makes it easy to run regular tasks on the child sites, but one of the active plugins might end up creating a floor of cron events. That alone could end up killing the site from being usable. WP-CLI is a very handy tool to have in your arsenal. The more you use it, the easier it will keep making common tasks that you will run into.