Learn Web Design, Coding & More. No Risk. No Contracts. Learn More

How to Remove Discontinued WordPress Plugin Cron Job


Most plugins on the WordPress repository are poorly coded. I discovered that some plugins that I have deactivated and even removed still have their database tables (not a big deal anyway) and cron job running.

A cron job is a *nix command for scheduling jobs (commands or shell scripts) server to complete repetitive tasks automatically.

WordPress rely greatly on Cron job for scheduling activities. For example, setting WordPress to close blog commenting after certain days, deleting comment in spam and trash after 30 days etc.

When using a plugin that has option to automate and/or schedule it activity, know that the plugin has a cron job running.
Some poorly coded plugins do not un-schedules or removes their cron job(s) upon deactivation and deletion which in turn increases server CPU usage and resources consumption. if you are on shared web hosting, God help you so you won’t get suspended.

Below is a screenshot of list of cron jobs generated by wpOptimix plugin.
list of active cron jobs

The ones marked in red are cron job of plugins that I no longer use, but they are still running and eating up server resources.

How to remove unwanted cron jobs

Removing / un-scheduling obsolete cron jobs can be achieved using this code snippet.

add_action("init", "remove_cron_job");
function remove_cron_job() {
 wp_clear_scheduled_hook("my_schedule_hook");
}

Change the my_schedule_hook to cron’s hook name and add the code in your theme’s function.php file.

To simplify the cron removal process, install and activate the FFF Cron Manager plugin.
This plugin will add an option to list, delete and restore cron jobs in WP Cron.
FF cron manager plugin page

Conclusion

We should always be careful and mindful of the plugins will install on our WordPress blogs. from the article, we saw how some poorly code plugins left their cron job still active even after they were deleted.

Don’t Want To Miss Our Update, Subscribe Now
About collizo4sky

Agbonghama Collins is a webdeveloper and an internet geek. I love writing and sharing the little idea & information i know. Hope you enjoyed my Article.

You can get in touch with him via these modes: Follow him on Twitter, add him on Facebook or on Google+