WPBeginner

Beginner's Guide for WordPress

  • Blog
    • Beginners Guide
    • News
    • Opinion
    • Showcase
    • Themes
    • Tutorials
    • WordPress Plugins
  • Start Here
    • How to Start a Blog
    • Create a Website
    • Start an Online Store
    • Best Website Builder
    • Email Marketing
    • WordPress Hosting
    • Business Name Ideas
  • Deals
    • Bluehost Coupon
    • SiteGround Coupon
    • WP Engine Coupon
    • HostGator Coupon
    • Domain.com Coupon
    • Constant Contact
    • View All Deals »
  • Glossary
  • Videos
  • Products
X
☰
Beginner's Guide for WordPress / Start your WordPress Blog in minutes
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
Recommended
WordPress Plugins
View all Guides

WPBeginner» Blog» Plugins» How to View and Control WordPress Cron Jobs

How to View and Control WordPress Cron Jobs

Last updated on September 20th, 2018 by Editorial Staff
108 Shares
Share
Tweet
Share
Pin
Free WordPress Video Tutorials on YouTube by WPBeginner
How to View and Control WordPress Cron Jobs

Recently, one of our readers asked if it was possible to view and control the WordPress cron job system in the dashboard. 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 schedule 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, etc.

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.

Irresponsible use of WordPress cron by plugins can slow down your website. Specially, 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.

WordPress Cron events

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, yoast seo uses wpseo_ 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.

Editing a cron in WordPress

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.

Modifying cron settings

Once you are done, click on the save changes button to store your settings.

Adding Your Own Cron Events in WordPress

WP Control 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.

Add custom cron event in WordPress

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 are 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.

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 ultimate guide to speed up WordPress and boost performance.

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.

108 Shares
Share
Tweet
Share
Pin
Popular on WPBeginner Right Now!
  • How to Properly Move Your Blog from WordPress.com to WordPress.org

  • Google Analytics in WordPress

    How to Install Google Analytics in WordPress for Beginners

  • How to Start Your Own Podcast (Step by Step)

    How to Start Your Own Podcast (Step by Step)

  • How to Fix the Error Establishing a Database Connection in WordPress

    How to Fix the Error Establishing a Database Connection in WordPress

About the Editorial Staff

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi. Trusted by over 1.3 million readers worldwide.

The Ultimate WordPress Toolkit

19 Comments

Leave a Reply
  1. Paul Barrett says:
    Nov 29, 2020 at 6:49 am

    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?

    Reply
    • WPBeginner Support says:
      Nov 30, 2020 at 11:29 am

      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.

      Reply
  2. Matt K says:
    May 17, 2020 at 4:18 pm

    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?

    Reply
    • WPBeginner Support says:
      May 19, 2020 at 9:02 am

      It would depend on the specific chron job, if you reach out to the plugin’s support they should be able to assist

      Reply
  3. Heinz says:
    Apr 24, 2020 at 4:22 am

    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?

    Reply
    • WPBeginner Support says:
      Apr 24, 2020 at 10:27 am

      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/

      Reply
  4. Andre Hesdahl says:
    Oct 18, 2018 at 12:17 pm

    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’);
    }

    Reply
  5. Jeff says:
    Jun 29, 2018 at 9:22 pm

    Thanks for the article. Interesting to see the number of plugins that have cron jobs running often. Great peak under the hood plugin…

    Reply
  6. David says:
    Apr 26, 2018 at 10:52 am

    How can i configure the cron to every half hour?

    Reply
  7. hazel beaver says:
    Apr 26, 2018 at 6:07 am

    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?

    Reply
  8. Janson says:
    Apr 24, 2018 at 8:43 pm

    Does this work in Multi-site? Can one control crons for all instances in a multisite scenario?

    Reply
  9. Oleg says:
    Mar 14, 2018 at 1:49 pm

    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,

    Reply
  10. beny salim says:
    Nov 15, 2017 at 10:47 am

    how can i add Recurrence like five minutes, ten minutes

    Reply
  11. Ahmad Sayeed says:
    Sep 30, 2017 at 9:16 am

    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

    Reply
  12. Sunny says:
    Jul 5, 2017 at 6:00 pm

    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.

    Reply
  13. Aniket Ashtikar says:
    Mar 10, 2017 at 12:14 am

    Is that ‘my_task_hook’ cron hook rightly mentioned there at line 2 or should that rather be changed to ‘wpb_custom_cron’?

    Reply
  14. Matt says:
    Feb 8, 2017 at 3:45 am

    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.

    Reply
  15. Pam M says:
    Jan 17, 2017 at 11:52 am

    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.

    Reply
  16. Nigam says:
    Jan 6, 2017 at 1:19 am

    Hi

    When I am going to refresh the page of WP-Cron Events from wordpress admin then only run the event.

    Reply

Leave a Reply Cancel reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

Over 1,320,000+ Readers

Get fresh content from WPBeginner

Featured WordPress Plugin
All in One SEO logo
All in One SEO
Improve website SEO rankings with AIOSEO plugin. Learn More »
How to Start a Blog How to Start a Blog
I need help with ...
Starting a
Blog
WordPress
Performance
WordPress
Security
WordPress
SEO
WordPress
Errors
Building an
Online Store
Useful WordPress Guides
    • 7 Best WordPress Backup Plugins Compared (Pros and Cons)
    • How to Fix the Error Establishing a Database Connection in WordPress
    • Why You Need a CDN for your WordPress Blog? [Infographic]
    • 30 Legit Ways to Make Money Online Blogging with WordPress
    • Self Hosted WordPress.org vs. Free WordPress.com [Infograph]
    • Free Recording: WordPress Workshop for Beginners
    • 24 Must Have WordPress Plugins for Business Websites
    • How to Properly Move Your Blog from WordPress.com to WordPress.org
    • 5 Best Contact Form Plugins for WordPress Compared
    • Which is the Best WordPress Popup Plugin? (Comparison)
    • Best WooCommerce Hosting in 2020 (Comparison)
    • How to Fix the Internal Server Error in WordPress
    • How to Install WordPress - Complete WordPress Installation Tutorial
    • Why You Should Start Building an Email List Right Away
    • How to Properly Move WordPress to a New Domain Without Losing SEO
    • How to Choose the Best WordPress Hosting for Your Website
    • How to Choose the Best Blogging Platform (Comparison)
    • WordPress Tutorials - 200+ Step by Step WordPress Tutorials
    • 5 Best WordPress Ecommerce Plugins Compared
    • 5 Best WordPress Membership Plugins (Compared)
    • 7 Best Email Marketing Services for Small Business (2020)
    • How to Choose the Best Domain Registrar (Compared)
    • The Truth About Shared WordPress Web Hosting
    • When Do You Really Need Managed WordPress Hosting?
    • 5 Best Drag and Drop WordPress Page Builders Compared
    • How to Switch from Blogger to WordPress without Losing Google Rankings
    • How to Properly Switch From Wix to WordPress (Step by Step)
    • How to Properly Move from Weebly to WordPress (Step by Step)
    • Do You Really Need a VPS? Best WordPress VPS Hosting Compared
    • How to Properly Move from Squarespace to WordPress
    • How to Register a Domain Name (+ tip to get it for FREE)
    • HostGator Review - An Honest Look at Speed & Uptime (2020)
    • SiteGround Reviews from 4196 Users & Our Experts (2020)
    • Bluehost Review from Real Users + Performance Stats (2020)
    • How Much Does It Really Cost to Build a WordPress Website?
    • How to Create an Email Newsletter the RIGHT WAY (Step by Step)
    • Free Business Name Generator (A.I Powered)
    • How to Create a Free Business Email Address in 5 Minutes (Step by Step)
    • How to Install Google Analytics in WordPress for Beginners
    • How to Move WordPress to a New Host or Server With No Downtime
    • Why is WordPress Free? What are the Costs? What is the Catch?
    • How to Make a Website in 2020 – Step by Step Guide
Deals & Coupons (view all)
Advanced Coupons
Advanced WooCommerce Coupons
Get 50% off the Advanced Coupons smart coupons plugin for WooCommerce.
WP Mail SMTP Coupon
Get $50 off WP Mail SMTP Pro so you can ensure all your WordPress emails reach the inbox.
Featured In
About WPBeginner®

WPBeginner is a free WordPress resource site for Beginners. WPBeginner was founded in July 2009 by Syed Balkhi. The main goal of this site is to provide quality tips, tricks, hacks, and other WordPress resources that allows WordPress beginners to improve their site(s).
Join our team: We are Hiring!

Site Links
  • About Us
  • Contact Us
  • FTC Disclosure
  • Privacy Policy
  • Terms of Service
  • Free Blog Setup
  • Free Business Tools
Our Sites
  • OptinMonster
  • MonsterInsights
  • WPForms
  • SeedProd
  • Nameboy
  • RafflePress
  • Smash Balloon

Copyright © 2009 - 2021 WPBeginner LLC. All Rights Reserved. WPBeginner® is a registered trademark.

Managed by Awesome Motive | WordPress hosting by SiteGround | WordPress CDN by MaxCDN | WordPress Security by Sucuri.