Recently, one of our readers asked if it was possible to view and control the WordPress cron job system in the dashboard. In our experience, this is a question that many WordPress users have, especially as they become more familiar with how WordPress operates behind the scenes.
If you’re not familiar, Cron is a technology to run scheduled tasks on web server. WordPress comes with its own built-in cron that allows it to perform scheduled tasks such as checking for updates, publishing scheduled posts, etc.
In this article, we will show you how to view and control WordPress cron jobs.
What is WordPress Cron? How it Works?
Cron is a technical term used for commands to run on scheduled time or at regular intervals. Most web servers use it to maintain the server and run scheduled tasks.
WordPress comes with its own cron system which allows it to perform scheduled tasks. For example, checking for updates, deleting old comments from trash, publishing scheduled posts, and so on.
WordPress plugins can also use it to perform tasks specified by you. For example, your WordPress backup plugin can use WordPress cron to automatically create backups at given schedule.
However, irresponsible use of WordPress cron by plugins can slow down your website. Especially, if you are on shared hosting.
If a plugin frequently performs resource intensive tasks, then you need to identify the issue and fix it.
Let’s take a look at how to view and control the WordPress cron system without writing any code.
View and Control WordPress Cron System
First thing you need to do is install and activate the WP Crontrol plugin. For more details, see our step by step guide on how to install a WordPress plugin.
Upon activation, you need to visit Tools » Cron Events page to control cron settings.
You will see a list of all cron events scheduled to run on your site using the WordPress cron system.
In the first column, you will see the name of the hook that runs the cron.
Hook names usually give you a hint at what this particular event does.
Most default WordPress hooks begin with a wp_ prefix, like wp_update_plugins, wp_update_themes, etc.
Your WordPress plugins may or may not use their own prefixes for their hooks. For example, All in One SEO uses aioseo_ prefix
.
You will also get to see when a cron will run next, and the time interval between next run.
The last column on the list allows you to edit, delete, or run a cron event.
Important: Be very careful about what you do with cron events and never delete a default WordPress cron event.
Now, let’s suppose you see a cron event created by a WordPress plugin that is quite resource intensive.
First, you should check the plugin’s settings to see if there is an option to control it from there. If there isn’t, then you can click on the ‘Edit’ link next to the cron event to change it.
Clicking on the Edit button will open the ‘Modify Cron Event’ tab down below.
Here, you can change how often you want the event to run.
Once you’re done, click on the ‘Modify Cron Event’ button to store your settings.
Adding Your Own Cron Events in WordPress
The WP Crontrol plugin makes it easy to add your own cron jobs to WordPress. Simply visit Tools » Cron Events page and scroll down to ‘Add Cron Event’ tab.
First, you need to provide a hook name for your cron event. Hook names cannot have spaces or special characters.
If the function you want to execute requires arguments, then you can provide those arguments.
Next, you need to tell WordPress when to run the cron next time. You can enter ‘now’ which will trigger cron immediately, ‘tomorrow’, ‘+2 days’, or ’25-02-2020 12:34:00′.
Lastly, you need to select a schedule. You can select hourly, twice daily, daily, or once a week. You can also make it non-repeating event.
Once you’re done, click on the ‘Add Cron Event’ button to save your changes.
You will notice that your cron event will now appear in the events list.
However, currently it does nothing because you haven’t told WordPress what to do when this event is triggered.
You will need to add your hook and a function that runs when the cron hook is triggered.
add_action( 'wpb_custom_cron', 'wpb_custom_cron_func' );
function wpb_custom_cron_func() {
wp_mail( 'you@example.com', 'Automatic email', 'Automatic scheduled email from WordPress to test cron');
}
Don’t forget to use your own email address.
This function simply sends a test email to you when the cron runs. You can now scroll up the page and click on the ‘Run Now’ link next to your cron event to test it out.
Note: Using cron requires intermediate level programming and WordPress development skills. If you don’t have these skills, we recommend hiring a WordPress developer.
That’s all we hope this article helped you learn how to view and control WordPress cron jobs. You may also want to see our guide on how to bulk install your favorite WordPress plugins or our expert picks of the best WordPress security plugins.
If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.
Mrteesurez
Thank you so much for introducing this topic and helping us better understand WordPress Cron jobs. Your detailed explanation really clarified how they work and how to manage them effectively. I appreciate the insights you’ve shared; it’s empowering to have this knowledge to keep our sites running smoothly. Thanks again for your valuable article!
Paul Barrett
We run cron at server level because wp-cron overloads teh server. There’s is nothing on our site that is so time-critical the jobs need to running frequently. If we set the frequency to say daily, would WordPress have a problem?
WPBeginner Support
It would heavily depend on what is being done on the site and when. We do not have a specific recommendation for what can be delayed to that extent.
Admin
Matt K
When I go to change the the recurrence on the Hooks, they just get changed back. Something isn’t right. Do I need to disable WP crons in wp-config.php first?
WPBeginner Support
It would depend on the specific chron job, if you reach out to the plugin’s support they should be able to assist
Admin
Heinz
Can I deactivate or even delete WP Control plugin in after having set a cron job, so I don’t have too many plugins running and slow down the website?
WPBeginner Support
Yes, as long as you’ve used one of the default schedules (such as daily). If you’ve added a custom schedule any event that uses it will run once more but won’t repeat after that.
The plugin should not cause a slowdown of your site, for a better understanding of how WordPress plugins affect your site you may want to take a look at our article here:
https://www.wpbeginner.com/opinion/how-many-wordpress-plugins-should-you-install-on-your-site/
Admin
Andre Hesdahl
I am a newbee with WordPress and don’t know where to put (or how to execute) the code:
add_action( ‘wpb_custom_cron’, ‘wpb_custom_cron_func’ );
function wpb_custom_cron_func() {
wp_mail( ‘you@example.com’, ‘Automatic email’, ‘Automatic scheduled email from WordPress to test cron’);
}
Jeff
Thanks for the article. Interesting to see the number of plugins that have cron jobs running often. Great peak under the hood plugin…
David
How can i configure the cron to every half hour?
hazel beaver
When I check the cron schedule the dates shown in the ‘next run’ column are all in the past. Does that mean they are not running?
In the past I think I added ‘true’ in the wp config file to stop automatic wp updates from breaking my site…. could this be the cause?
Janson
Does this work in Multi-site? Can one control crons for all instances in a multisite scenario?
Oleg
Great article, but no need for
if ( ! wp_next_scheduled( ‘wpb_custom_cron’ ) ) {
wp_schedule_event( time(), ‘hourly’, ‘my_task_hook’ );
}
this part is done in the plugin,
beny salim
how can i add Recurrence like five minutes, ten minutes
Ahmad Sayeed
I tested you given example. It works like a superman. But please give us an example to send parameter. I have added the function while creating the even. But I don’t know how to use them on PHP function.
Please give us an example
Sunny
My website is coming up with a long wp cron string after my URL and I cant get rid of it. Any thoughts?
?doing_wp_cron=1499261576.8675799369812011718750 comes up after my url and its making me look really spammy. Your insight would be appreciated.
Aniket Ashtikar
Is that ‘my_task_hook’ cron hook rightly mentioned there at line 2 or should that rather be changed to ‘wpb_custom_cron’?
Matt
Do you know if its possible to visit a link in the wp-admin area? I have a plugin that adds admin features to my wordpress site but I really want this scheduled to happen every 24 hours. I have the link but obviously am required to be logged in.
Pam M
Do you need that first if statement shown in the sample code? It looks like it would override the ability to schedule and unschedule in the WP Crontrol plugin.
Your example worked nicely when I scheduled the job in the plugin and tested it with the Run Now option. I’ll see if I get an email at the scheduled time too.
Thanks for the helpful background info.
Nigam
Hi
When I am going to refresh the page of WP-Cron Events from wordpress admin then only run the event.