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
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;
To delete a specific cron event:
To test if WP Cron is working correctly on a site:
To delete all cron events from the options database:
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.
Manage all your WordPress sites with the MainWP Dashboard
WordPress Management for Professionals
Are you ready to go Pro?
All MainWP Pro Extensions are available through one of our convenient bundled packages.
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.