Delete WordPress cron events completely and check open WP cron events

How to check and delete Wordpress Cron entries, I'll show you in this guide.

Today I had the case again that I had a customer's WordPress site that ran agonizingly slow despite being hosted on a "managed server". When calling the WP-Admin you could see that he repeatedly accessed the wp-cron.php file and the admin pages sometimes took between 30 seconds and 2 minutes to open. The memory requirement was also quite high with over 200 MB RAM. All indications that something was not going quite well.

What is WP Cron?

WP Cron is a kind of internal cron job that WordPress uses to carry out regular cleaning tasks and to run administrative scripts. In the case of WordPress sites that have few visitors, it can happen that WordPress cannot run the cron jobs often enough due to the few tasks. In most cases, however, this is rarely the case, as there are only a few regular tasks in the WP cron list. These are then already done when you call up the WP admin area.

How to check and delete WordPress Cron entries, I'll show you in this guide.

How to check and delete WordPress Cron entries, I'll show you in this guide.

View the list of WP Cron events

My suspicion was that WordPress has to process a lot of cron jobs in the background, which are then always done when the admin is called normally. Now WordPress itself does not offer the possibility to view this list of the cron events, but with the plugin "WP-Crontrol"You get a list in the admin area that gives you information about the individual tasks that are currently still in the WP-Cron's queue. This looks like this, for example:

Check the list of WP-Cron events: This looks like this with the WP-Crontrol plug-in, for example.

Check the list of WP-Cron events: This looks like this with the WP-Crontrol plug-in, for example.

In the case of the extremely slow WordPress installation, there were over 40.000 entries in the list that were generated by the "Huge-IT-Gallery" plugin and that were also steadily more instead of less. The WP-Crontrol plug-in offers a list of all the cron events and you can also delete them individually using a button, but with over 40.000 entries a "more comprehensive" solution had to be found.

Delete all WP-Cron entries at once

Fortunately, the Internet offers a wide range of information options and so I came across the command »delete_option ('cron');«, which deletes all entries in the wp_options table that match the "cron" area.

delete_option ('cron');

This will delete all existing cron events that WordPress currently has in the queue in one fell swoop. In order for the command to be executed, you have to include it in the "functions.php" file in the theme. Then call up any WordPress page in the frontend and then delete the line again. If the theme does not have a "functions.php" file, you can copy it into the headerphp, footer.php or other files that are executed when the WordPress site is called up.

Here in the screenshot you can see where the command to delete all WP-Cron entries can be inserted. In my case it was briefly built into the functions.php in the folder of the current theme and then deleted again.

Here in the screenshot you can see where the command to delete all WP-Cron entries can be inserted. In my case it was briefly built into the functions.php in the folder of the current theme and then deleted again.

Correction of the "malefactor"

Now that all cron events had been deleted, WordPress ran really fast again. To check I looked again at the list of cron events with WP-Crontrol and saw that new entries from the Huge-IT-Gallery plugin are constantly being added. It would be just a matter of time before everything slows down again.

Since the plugin was still needed, I just looked for the string "cron" in the plugin's source code and commented out the corresponding lines that ensured that new cron events were created for WP-Cron. So the WordPress installation is now permanently cleaned up and nice, fast.

[sc name = "WordPress Help"]

 

 

-
Do you like my blog? Then I would be happy to receive a short review on Google. Easy leave something here for a moment - that would be great, thank you!

 

Effectively for free: iPhone 13 Mini and iPhone 13 deals with top conditions at Otelo - Advertisement

6 comments

  1. Heike says:

    Hallo,
    that sounds easy - great!
    But: if I simply delete ALL cron jobs, can there not be problems with cron jobs that I want to keep?
    Are the cron jobs of the other plugins simply created again?

    Thank you for the info & best regards
    Heike

    • Sir Apfelot says:

      Hello Heike!
      Yes, in principle we do not delete the cron jobs themselves, but their already planned execution in the future. The plugins then create it again without you having to do anything. VG! Jens

  2. Ricardo says:

    Hello, if I can ask a small, hopefully not too complex question. My WordPress plugin for sending newsletters ("The Newsletter") always gives me a warning: "The WodPress internal schedule is not triggered enough often. [...]" in its status display, all points are positive except for the point "Cron calls" which has the message "the blog cron system is NOT triggered enough often Trigger interval: average 423 s, max 1550 s, min 12 s"

    I looked at the whole thing in WP-Control, as described by them, and the event is carried out every 5 minutes.

    Do you have an approach that I could google for? or do you know such behavior and have a direct approach?

    Thanks in advance

    • Sir Apfelot says:

      Hello Ricardo! You probably have too few visitors on the blog to be able to reliably perform the cron job. WordPress almost always uses visitors to do the cron job on the side. The table provides for the setting of 5 minutes, which is why WP-Control shows it that way, but it is simply not triggered. The solution is pretty simple: You register with an external cronjob service such as DoTheJob.de or others (or use the cronjob from hosting) and call up wp-cron.php automatically every 2-5 minutes. The complete URL is then for example https://www.sir-apfelot.de/wp-cron.php - just with your domain. VG! Jens

  3. Jens says:

    Hallo,
    great plugin, thanks! I am currently building the cronjob of a page on the server-supported call, i.e. with WordPress cron deactivated.
    The plugin did a good job.
    Greetings, Jens

Leave a Comment

Your e-mail address will not be published. Required fields are marked with * .