WordPress Guide: How to View and Control WordPress Cron Jobs?

WordPress Guide: How to View and Control WordPress Cron Jobs?

Are you willing to know How to View and Control WordPress Cron Jobs? Cron is a technique for running scheduled tasks on the web server. WordPress comes with its own built-in cron, which allows it to perform scheduled tasks like as publishing schedule posts, checking for updates, etc.

Here, in this post, we are going to illustrate you how to view and control WordPress Cron Jobs.

What is WordPress Cron and How it Works?

The Cron is a technical word that is 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.

However, WordPress comes with its own cron system that permits it to perform scheduled tasks. For example, deleting old comments from trash, checking for updates, etc.

Plugins can also use it to accomplish the tasks specified by you. For example, your WordPress Backup plugin can use WordPress cron to create backups automatically on a given schedule.

The irresponsible use of WordPress Cron by the plugin can slow down your WordPress site. Specifically, if you are on shared hosting.

If a plugin frequently performs resource intensive works, you need to identify and fix the problem.

Let’s take a look at:

How to view and control WordPress Cron Jobs system without any coding

View and Control WordPress Cron System

View and Control WordPress Cron Jobs

  • You will see all events schedule list that runs on your site by using the WordPress Cron system.
  • In the first column, you will see the name of the hook that runs the cron. Usually, Hook names give you a hint about what this particular event does. The mostly default WordPress hook starts with a wp_ prefix such as wp_update_themes, wp_update_plugins, etc.
  • However, your WordPress plugins can or cannot be used their own prefixes for their hooks. For example, Yoast SEO uses the wpseo_ prefix.
  • Also, you will see that when a cron will run next, and the time interval between next run.
  • The last column in the list permits you to delete, edit, or run an event.

Important Note: Be very careful about what you do with events and never delete the default WordPress cron event. Now suppose that you see a cron event created by a WordPress plugin that quite resources intensive.

  • Firstly, you should check the settings of the plugin to see if there is an option to control it from there. If not, you can click on the ‘Edit’ link to change it that is next to the cron event.

View and Control WordPress Cron Jobs

  • By clicking the ‘Edit’ button will open the ‘Modify Cron Event’ tab below.
  • Now, here you can change how often you want to run the event.

View and Control WordPress Cron Jobs

  • Once you’ve done, click the Save Changes button to save your settings.

Adding Your Own Cron Events in WordPress

WP Control Plugin makes it easy to add your own cron jobs to WordPress.

  • Simply go to the Tools>>Cron Events Page and scroll down to the ‘Add Cron Event’ tab.

View and Control WordPress Cron Jobs

  • First, you have to offer a hook name for your event. The hook names cannot contain spaces or special characters.
  • If the function requires arguments that you want to execute, then you can provide those arguments. Next time when to run the cron, you have to tell the WordPress.
  • You can enter ‘now’ that will trigger cron immediately, ‘tomorrow’, ‘+2 days’, or ’25 -02-2020 12:34:00′.
  • Lastly, you have to choose a schedule you can choose hourly, twice daily, daily or weekly. Also, you can create it the non-repetitive event.
  • Once you’re done, then click the Add Cron Event button to store your changes.
  • You will see that your event will now appear in the event list.
  • Currently, it does nothing because you have not told WordPress that what to do when this event begins.
  • You will have to add your hook and function that runs when cron hook is triggered.
if ( ! wp_next_scheduled( ‘wpb_custom_cron’ ) ) {
wp_schedule_event( time(), ‘hourly’, ‘my_task_hook’ );
}add_action( ‘wpb_custom_cron’, ‘wpb_custom_cron_func’ );function wpb_custom_cron_func() {
wp_mail( ‘[email protected]’, ‘Automatic email’, ‘Automatic scheduled email from WordPress to test cron’);
}
  • Remember that, don’t forget to use your own email address.
  • This function sends you a test email when the cron is running. Now you can scroll up the page and test it by clicking the ‘Run Now’ link next to your event.

CONCLUSION

Wrapping this all end! We have discussed How to View and Control WordPress Cron Jobs. We hope this post helped you to learn it.

Read the above steps carefully and View and Control Cron Jobs.

If you are facing any problem to view this, let me know in the comment section provided below! If you liked this post, please share it with your peers!

We have a team of skilled experts who will help you to resolve your issue related to Install WordPress Theme, dial our Toll-Free number + 1 844 897 0441.

Recommended Blogs:



Leave a Reply