WordPress uses an wp-cron.php to schedule and execute plugins in a scheduled manner. Plugins add hooks to wordpress with time interval in between they run. But often at times this can lead to adding load to your server and slowing down your site. And as it seems some plugins do not clean up their cron hooks when you uninstall them causing wordpress to try and accomplish what isn’t there. Here is something that is going to help you clear the crons scheduled on your WordPress installation.
So we are going to check what wp-cron is set to run and then remove them if needed. I spent a good amount of time trying to figure this out as there weren’t any clear answer by searching on Google. Firstly you’ll need a plugin called “Cron View“. Cron View is an old plugin but seems to still work perfectly to browse cron hooks on WordPress.
So after activating Cron View, head to Admin Dashboard > Tools > What’s in Cron?. Here you will find all the events that WP Cron is set to run with their next due date, schedule, hook name and arguments. There might be a lot of cron jobs if you have high number of plugin automating tasks. The Cron View however doesn’t show the name of the plugin which created the hook so be careful as which cron schedule you want to remove. I only removed hooks for plugins that i no longer have but were still on WP Cron schedule. I did a quick search on Google for the hook name to find which they were related to.
Once you find the crons you don’t need, list them in a text file so you can remove them. Now we will add them to a wordpress function (wp_clear_scheduled_hook( ‘cron_hook_name’ );) that clears all the schedule related to that hook so your wp-cron doesn’t schedule that any more. This is to be added at the end of wp-cron.php file on your host just before the die() line.
wp_clear_scheduled_hook( ‘cleanup_openid’ );
wp_clear_scheduled_hook( ‘peacedev_hourly_event’ );
wp_clear_scheduled_hook( ‘akismet_scheduled_delete’ );
wp_clear_scheduled_hook( ‘newsletter_feed’ );
Save the wp-cron.php and then execute the cron file by going to your wp-cron.php link on your browser. Which normally is yourwpsite.com/wp-cron.php. Once you run the file, check the What’s in Cron settings to check that those hooks are removed. After that you’re save to remove the code from your wp-cron.php file as well.