Hosting Tutorial & Guide

How to Control WordPress Cron Jobs from the Admin Area

updated on Feb 14, 2017
How to Control WordPress Cron Jobs from the Admin Area Cron is an operating system or server-side command that enables tasks to be performed automatically at a specific time or with specific intervals. The WordPress cron system, then, is built in the core features, allowing the web server to execute scheduled jobs.

WordPress comes with some built-in cron jobs, such as deleting the drafts from trash, checking for updates, publishing the scheduled posts, etc. Many plugins, like the backup plugins, also create cron jobs to perform automatic tasks at the given intervals. Also, you can create your own cron jobs after accessing your server, but this indeed requires medium-level technical skills.

Cron jobs are very useful, as they can save you from a lot of repeated works and get rid of much trouble. However, when cron jobs run with a high frequency, they could lead to the excessive usage of your server resource and a slowness of your entire site. Therefore, you must keep a close eye on those resource-intensive tasks and make sure they are not performed at an improper interval that adds heavy loads to your server, especially when your WordPress site resides on a shared server.

If you doubt that some tasks are performed too frequently on your site and have caused bad results, we'd suggest you check the cron jobs on your WordPress site. In below, we will tell how to do this from the WordPress admin area, without logging into your server. Besides, we will also show you how to create new cron jobs as you like when there is a need.

View and Edit the Existing Cron Jobs on Your WordPress Site

There is an easy way to view all the existing cron jobs that are running on your WordPress site – by using a plugin called WP Control. This great plugin allows you to manage cron jobs directly from the WordPress admin area so that you can check all the cron details in an easy-to-understand manner without touching the complicated code lines on your server.

WP Control

View WordPress cron jobs with WP Control

To use WP Control requires you to complete the plugin installation and activation. Then, you will find a "Cron Events" submenu under the "Tools" menu in WordPress dashboard. Clicking on "Cron Events", you can access a list of all the cron events that are scheduled in your WordPress cron system.

For those cron events, you can get the following details.
  • Action Name – The hook name used to run the cron, which usually gives you some ideas about what the cron event is. For example, wp_version_check is a cron job that automatically checks the WordPress version you are using. Some hooks generated by plugins also begin with the plugin name.
  • Next Run – The next time the cron events will run.
  • Recurrence – The time interval between each run of the cron events.
WordPress Cron Events

Edit WordPress cron jobs

Under the last column of the cron event list, you will get some options to control the cron jobs on your WordPress site. These include "Edit", "Run Now" and "Delete". The second option allows you to ignore the next schedule and manually run the cron job immediately, and the third one enables you to delete cron jobs, of course. However, we'd suggest you be careful with the deletion feature and try not to delete the default WordPress cron jobs.

With the "Edit" option, then, you can edit a cron job. This feature is recommended if you find a cron job is resource-intensive. After clicking on the "Edit" link, you will be brought to a "Modify Cron Event" tab where you are able to change the action name, add arguments, and change the schedule of the cron job. For a resource-intensive cron job, you can lower the frequency it runs.

Modify Cron Events

Add a New Cron Job for Your WordPress Site

Besides allowing you to view and edit the existing cron jobs on your site, WP Control also makes it quite easy to add new cron jobs for the tasks you want to schedule by yourself. What you should do is to open the "Add Cron Event" tab, and fill out the following things.
  • Action Name – Enter a valid hook name without any special characters or spaces.
  • Arguments (Optional) – Offer arguments if necessary.
  • Next Run – Specify the time that the cron job will run for the first time. A calendar is available, making the selection of time as easy as possible.
  • Recurrence – Select the interval that WordPress uses to run the cron job.
At last, click on the "Add Cron Event" button to get the new cron job created.

Add New Cron Event

As soon as you have created the cron job, you need to add the actions that will be triggered by the cron job. This requires you to add some code to the functions.php file of your theme. The function will look like this.

if ( ! wp_next_scheduled( 'wp_send_mail' ) ) {
  wp_schedule_event( time(), 'weekly', 'my_task_hook' );
}

add_action( 'wp_send_mail', 'wp_send_mail_func' );

function wp_send_mail_func() {
  wp_mail( 'admin@yourdomain.com', 'Automatic email', 'Send test email automatically');
}

When creating your own cron job, you have to modify the function to your own needs, which demands some programming skills.

After adding the function, you can go back to your WordPress site, find the cron job you have just created, and run it to test whether things are right.