• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
NameHero Blog

NameHero Blog

Web Hosting Tips & Resources From NameHero

  • Hosting
    • Web Hosting
    • VPS Hosting
    • WordPress Hosting
    • WooCommerce Hosting
  • Reseller
  • Enterprise
  • Domains
  • Account
  • Blog Home
  • Categories

How To Clean Up WordPress Cron Jobs

Bhagwad Park

Published on: September 14, 2022

Categories: WordPress 0

We don’t often think about WordPress cron jobs. They occur in the background periodically, and the only time the average user needs to worry about them is when something goes wrong. It’s only when something goes wrong that most WordPress users even become aware of something called “cron.” But for those who already know what cron is, here’s how to debug and clean up your cron queue easily using a simple plugin.

Errors in Cron

Because of the frequency with which cron runs and the resources, it can consume, I recommend disabling cron on WordPress and setting it up to run manually to control the frequency and prevent scripts from potentially running dozens of times a day when they only need to do so once. I’ve configured my server to send me error notifications, and a while back, I started getting these for my site WP-Tweaks.com:

Cron Error Message
Cron Error Message

This is the HTML output of a standard WordPress error page. I copied all the contents, pasted them into a file called “test.html,” and opened it in my browser to see what it was about. Just a regular WordPress error generated by the script named in the first few lines of the e-mail.

To debug, I had to better understand what was happening inside cron and which hooks it was calling.

WP Crontrol to the Rescue

The tool best suited to the problem is a WordPress plugin called WP Crontrol. After downloading and installing the plugin, you can access all your cron events in WordPress by clicking “Settings” from the plugin page, as shown here:

WP Control Events
WP Control Events

In the next screen, you can see a list of hooks that run in wp-cron.php:

Useless Cron Jobs
Useless Cron Jobs

Each of these hooks corresponds to a specific “Action” in the WordPress PHP files – either the functions.php or elsewhere. Unfortunately, the plugin doesn’t tell you which file contains the script. But if there’s an error message, it should give the script name and the line number.

As you can see above, some of these hooks have no action. Removing them should be perfectly safe by clicking the “Delete” link.

Using WP Crontrol, you can change the schedule for each cron hook by assigning them an entry from the predefined “schedule” dropdown box in the edit screen or create an entirely new schedule.

Plugins that Don’t Clean up Behind Themselves

A major source of useless entries in WP Cron is deactivated or deleted plugins that didn’t do a good job of cleaning up after themselves. Another equally annoying source is plugins that no longer use a certain hook but leave it in Cron. Yoast SEO is a culprit in this regard, an example being the outdated wpseo-reindex-links hook with no action. Feel free to remove these and clear up your WordPress cron queue.

Getting Rid of the Cron Output

If you rather you didn’t hear from the WordPress cron system altogether, then I suggest you disable the output entirely. The best way to do this is to add the following after your manual cron command:

> /dev/null 2>&1

For example, I run WordPress cron by calling the wp-cron.php manually from my server’s cron queue using the “php” command. If I wanted to suppress the output, I would use this:

php https://[path to wp-cron.php] > /dev/null 2>&1

Save the changes, and you’re done.

Periodically Check WordPress Cron

Cleaning up your WordPress cron queue is good hygiene practice. Think of it as spring cleaning your WordPress installation, along with deleting old revision posts and outdated entries from wp_options. Make a note on your calendar to perform all these tasks once every few months, and you will have a happy WordPress installation!

Bhagwad Park Profile Picture
Bhagwad Park

I’m a NameHero team member, and an expert on WordPress and web hosting. I’ve been in this industry since 2008. I’ve also developed apps on Android and have written extensive tutorials on managing Linux servers. You can contact me on my website WP-Tweaks.com!

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Follow & Subscribe

Exclusive promos, content and more!

Most Popular Posts

Speed up your site: solving the WordPress slowdown

NameHero’s Recommended WordPress Plugin and Theme Setup (2023)

How To Increase The InnoDB Buffer Pool Size

How To Fix A Stuck All-in-One WP Migration Import

How To Add A Subdomain In Cloudflare

Top Categories

  • WordPress
  • WordPress Tutorials
  • Enterprise Hosting
  • WooCommerce
  • Web Hosting
  • Resellers
  • Website Security
  • Website Development
  • Website Performance
  • VPS Hosting
  • SEO Tips
  • Announcements
  • Domain Registration
NameHero

NameHero proudly provides web hosting to over 40,000 customers with 99.9% uptime to over 750,000 websites.

  • Master Card
  • Visa
  • American Express
  • Discover
  • Paypal
Products
  • Web Hosting
  • VPS Hosting
  • WordPress Hosting
  • WooCommerce Hosting
  • Reseller Hosting
  • Enterprise Hosting
  • Domains
Help & Support
  • NameHero Blog
  • Support
  • Knowledgebase
  • Announcements
  • Affiliates
Company
  • About Us
  • Contact Sales
  • Reviews
  • Uptime
  • We're Hiring

Copyright © 2023 NameHero, LLC. All rights reserved.

  • Privacy Policy
  • Terms of Use
  • Acceptable Use Policy
  • Payment Policy
  • DMCA