WordPress has its own built-in cron that allows it to perform tasks like checking for updates, publishing scheduled posts, and so on. We’ll show you how to view and control WordPress cron jobs in this article. One of our readers recently asked if the WordPress cron job system could be viewed and controlled from the dashboard. Cron is a web server technology that allows you to run scheduled tasks.
How Does It Work? What is WordPress Cron and how does it work?
It’s used by most web servers to keep the server up to date and run scheduled tasks. Cron is a technical term for commands that run at regular intervals or on a set schedule.
Checking for updates, deleting old comments from the trash, and so on. WordPress has its own cron system, which allows it to run tasks on a regular basis.
It can also be used by plugins to perform tasks that you specify.
Your WordPress backup plugin, for example, can use WordPress cron to create backups on a set schedule.
The use of WordPress cron by plugins in an irresponsible manner can cause your website to slow down. Particularly if you’re using shared hosting.
If a plugin frequently performs resource-intensive tasks, you should investigate and resolve the problem.
Let’s look at how to access and control the WordPress cron system without having to write any code.
The WordPress Cron System can be viewed and controlled.
See our step-by-step guide to installing a WordPress plugin for more information. The first step is to download and activate the WP Crontrol plugin.
To control cron settings, go to Tools » Cron Events page after activation.
The WordPress cron system will display a list of all cron events scheduled to run on your site.
The name of the hook that runs the cron is listed in the first column.
The name of the hook usually gives you a hint as to what the event is about.
Most default WordPress hooks, such as wp_update_plugins, wp_update_themes, and so on, start with a wp_ prefix.
Your WordPress plugins may or may not prefix their hooks with their own prefixes. All in One SEO, for example, uses the aioseo_ prefix.
You’ll also be able to see when the next cron will run, as well as the time interval between runs.
You can edit, delete, or run a cron event in the list’s last column.
Important: Use cron events with extreme caution, and never delete a default WordPress cron event.
Let’s say you come across a resource-intensive WordPress plugin that has created a cron event.
To begin, look through the plugin’s settings to see if there is a way to control it from there. If there isn’t, you can change it by clicking the ‘Edit’ link next to the cron event.
The ‘Modify cron event’ tab appears when you click the Edit button.
You can change how often the event runs from here.
When you’re finished, click the Save Changes button to save your changes.
Using WordPress to Create Your Own Cron Events
Adding your own cron jobs to WordPress is simple with the WP Control plugin. Simply go to Tools » Cron Events and select the ‘Add Cron Event’ tab from the drop-down menu.
For your cron event, you must first give it a name. Spaces and special characters are not allowed in hook names.
If the function you want to run requires arguments, you can supply them.
The next step is to tell WordPress when to run the cron again. You can enter ‘now’ to start cron right away, ‘tomorrow’, ‘+2 days’, or ‘25-02-2020 12:34:00′ to start cron later.
Finally, you must choose a schedule. You have the option of setting it to hourly, twice daily, daily, or once a week. You can also make it a once-in-a-lifetime event.
To save your changes, click the Add Cron Event button when you’re finished.
You’ll notice that your cron event has been added to the list of events.
However, because you haven’t told WordPress what to do when this event occurs, it currently does nothing.
You’ll need to include your hook as well as a function that will be executed when the cron hook is triggered.
Remember to use your personal email address.
You can now test your cron event by scrolling up the page and clicking the ‘Run Now’ link next to it. When the cron runs, this function simply sends you a test email.
Note that using cron necessitates intermediate programming and WordPress development abilities.
You might also be interested in our comprehensive guide to speeding up WordPress and improving performance. That concludes this article; we hope it was useful in teaching you how to view and control WordPress cron jobs.
You can also find us on social media sites such as Twitter and Facebook. Please subscribe to our YouTube Channel for WordPress video tutorials if you enjoyed this article.
Step-by-Step Instructions for Starting Your Own Podcast
15 Things You Must Do Before Changing WordPress Themes Checklist
Why is it so important to build an email list today? (6 Reasons)
How to Transfer Your Blog from WordPress.com to WordPress.org Correctly
Editorial Staff Information
Over 1.3 million readers around the world rely on it. WPBeginner’s Editorial Staff is a group of WordPress experts led by Syed Balkhi.
Nothing on our site is so time-sensitive that jobs must run on a regular basis. Would WordPress have a problem if we set the frequency to daily? Because wp-cron overloads the server, we run cron at the server level.
We don’t have any specific suggestions for what can be postponed to that extent. It would be highly dependent on what is being done and when on the site.
When I try to change the Hooks’ recurrence, they simply return to their previous state. Something isn’t quite right here. Is it necessary to disable WP crons first in wp-config.php?
It would depend on the specific chron job; however, if you contact the plugin’s support team, they should be able to help.
Is it possible to deactivate or even remove the WP Control plugin after creating a cron job in order to avoid having too many plugins running and slowing down the website?
Yes, as long as one of the default schedules (such as daily) was used. If you have a custom schedule, any event that uses it will run once more, but it will not repeat.
The plugin should not cause your site to slow down; for more information on how WordPress plugins affect your site, see our article here: https://kiuz.it/opinion/how-many-wordpress-plugins-should-you-install-on-your-site/
I’m new to WordPress and have no idea where to put (or how to execute) the following code: ‘wpb_custom_cron’, ‘wpb_custom_cron_func’ ); add_action( ‘wpb_custom_cron’, ‘wpb_custom_cron_func’ );
wp_mail(‘[email protected]’,’Automatic email’,’Automatic scheduled email from WordPress to test cron’); wpb_custom_cron_func() wp_mail(‘[email protected]’,’Automatic email’,’Automatic scheduled email from WordPress to test cron’);
Thank you for writing this article. This plugin gives you a sneak peek into what’s going on under the hood… It’s interesting to see how many plugins have cron jobs that run frequently.
How do I set the cron to run every half hour?
Does this imply that they aren’t on the move? When I look at the cron schedule, all of the dates in the ‘next run’ column are past.
I believe I added ‘true’ to the wp config file in the past to prevent automatic WordPress updates from breaking my site…. Could this be the source of the problem?
In a multisite environment, is it possible to control crons for all instances? Does this work in a multi-site environment?
It’s a great article, but there’s no need for it.
wp_schedule_event( time(), ‘hourly’, ‘my_task_hook’ ); if (! wp_next_scheduled( ‘wpb_custom_cron’ ) wp_next_scheduled( ‘wpb_custom_cron’ ) wp_next_scheduled( ‘wpb_custom_cron’ ) wp_next_scheduled( ‘wp
This is handled by the plugin.
How do I add a recurring event, such as five minutes or ten minutes?
While creating the event, I added the function. However, please provide an example of how to send a parameter. It functions as if it were a superhero. However, I’m not sure how to use them in a PHP function. I put your example to the test.
Please provide an example.
What are your thoughts on this? I can’t seem to get rid of a long wp cron string after my URL on my website.
Your opinion would be greatly appreciated. After my url,?doing_wp_cron=1499261576.8675799369812011718750 appears, making me appear spammy.
Is the cron hook ‘my_task_hook’ mentioned on line 2 correct, or should it be changed to ‘wpb_custom_cron’?
I have a plugin that adds admin features to my WordPress site, but I’d like it to happen every 24 hours or so. I have the link, but I must be logged in to use it. Do you know if a link in the wp-admin area can be visited?
It appears to override the WP Crontrol plugin’s ability to schedule and unschedule. Is the first if statement in the sample code required? Thank you for the background information. I’ll see if I get an email when it’s supposed to arrive. When I scheduled the job in the plugin and tested it with the Run Now option, your example worked perfectly.
When I refresh the WP-Cron Events page from the WordPress admin, I only run the event.