How To Delete Thousands of Crons in WordPress

I previously posted how to fix missed scheduled posts, this time on a related but different note I’m going to show you how to delete thousands of cron jobs all at once.

Now you must be asking, how did I get thousands of cron jobs? Well, I had a defunct plugin that was adding in new cron jobs over and over. I used Improved Cron to check out why my cron jobs weren’t firing, and found that it was flooded with cron jobs.

What’s interesting to note is a lot of plugins will add a cron job, but when you remove the plugin it doesn’t remove the cron job. So over years you can start to have a ton of junky cron jobs in there slowing everything down.

Delete WordPress cron jobs with phpMyAdmin: if you are familiar with phpMyAdmin, simply goto your WordPress database and open up the wp_options table. Do a search for crons.

1-26-2016 1-23-29 PM

Once you find the cron, simply delete it. Scary, but actually WordPress will automatically re-generate the field when necessary.

1-26-2016 1-23-46 PM

If you don’t know how to use phpMyAdmin, or are simply too scared, a neat trick you can do is to add this one line of code to your WordPress Theme functions.php file. If it doesn’t have it, then you can add it to any of the plugins:

delete_option( 'cron' );

Once you or anyone accesses your blog, this will delete that field. Then remove the code and you’re good to go! Now after doing this my cron jobs run much smoother.

How to Fix Missed Scheduled Posts in WordPress

I’ve never had this happen before, so I was a bit surprised today when I went to make a blog post and saw one was scheduled for this morning, but it said missed schedule in red letters next to it.

It turns out that WordPress isn’t exactly the best at making sure things go in a timely matter. We’re used to computers doing everything exactly on time every time. The way WordPress works, if someone visits your site *around* the time it’s supposed to happen, it does it while that visitor is on your site.

In other words, if you schedule a post and nobody happens to come to your blog at that time..  It won’t post!

There is a simple solution to this..  Add a cron job! All you have to do is login to cPanel and add a new cron job. You’ll find cron jobs under advanced, but don’t be scared, I’ll walk you through it!



Next select the One Per 5 Minutes option, and enter the following code for the command. Just be sure to replace with your domain. Also, if your blog is hosted in a subfolder, add that too.

wget -O /dev/null -o /dev/null

The geekyness of this is that it will run the cron job every 5 minutes, and it won’t save the results anywhere. If you were to skip out the /dev/null stuff you’d end up with a bunch of files in your home directory, or worse, an email every 5 minutes.

That’s all there is to it. Then the server will run the WordPress cron job every 5 minutes. You’ll never miss a scheduled post again!