WordPress.org

Ready to get started?Download WordPress

Plugin Directory

WP Crontrol

WP Crontrol lets you view and control what's happening in the WP-Cron system.

What's the use of adding new cron schedules?

Cron schedules are used by WordPress and WordPress plugins to allow you to schedule events to be executed at regular intervals. Intervals must be provided by the WordPress core or a plugin in order to be used. An example of a plugin that uses these schedules is WordPress Database Backup. Out of the box, only daily and hourly backups are supported. In order to do a weekly backup, a weekly cron schedule must be entered into WP Crontrol first and then the backup plugin can take advantage of it as an interval.

How do I create a new PHP cron event?

In the Tools -> Crontrol admin panel, click on the "Add new PHP event" link underneath the cron event table. In the form that appears, enter the schedule and next run time in the boxes. Next run is the next time that the hook will execute. This can be entered in using GNU Date Input Formats, but often now is good enough. The event schedule is how often your hook will be executed. If you don't see a good interval, then add one in the Settings -> Cron Schedules admin panel. In the "Hook code" area, enter the PHP code that should be run when your cron event is executed. You don't need to provide the PHP opening tag (<?php).

How do I create a new regular cron event?

There are two steps to getting a functioning cron event that executes regularly. The first step is telling WordPress about the hook. This is the part that WP Crontrol was created to provide. The second step is calling your function when your hook is executed. You've got to do that on your own, but I'll explain how below.

Step One: Adding the hook

In the Tools -> Crontrol admin panel, enter the details of the hook. You're best off having a hookname that conforms to normal PHP variable naming conventions. This could save you trouble later. Other than that, the hookname can be whatever you want it to be. Next run is the next time that the hook will execute. This can be entered in using GNU Date Input Formats, but often now is good enough. The event schedule is how often your hook will be executed. If you don't see a good interval, then add one in the Settings -> Cron Schedules admin panel.

Step Two: Writing the function

This part takes place in PHP code (for example, in the functions.php file from your theme). To execute your hook, WordPress runs an action. For this reason, we need to now tell WordPress which function to execute when this action is run. The following line accomplishes that:

add_action('my_hookname', 'my_function');

The next step is to write your function. Here's a simple example:

function my_function() {
        wp_mail('hello@example.com', 'WP Crontrol', 'WP Crontrol rocks!');
}

Do I really need the entire `wp-crontrol` directory?

No, you can get rid of the whole directory and just use wp-crontrol.php if you wish. If you want to use WP-CLI then you'll need to include class-wp-cli.php too.

Which WP-CLI commands are available?

  • wp crontrol list-events Lists the scheduled events on your site.
  • wp crontrol run-event <hook> Runs the next scheduled WP-Cron event for the given hook
  • wp crontrol delete-event <hook> Deletes the next scheduled WP-Cron event for the given hook
  • wp crontrol list-schedules Lists the available WP-Cron schedules on your site.
  • wp crontrol test Performs a WP-Cron spawning test to make sure WP-Cron can function as expected.

Note that WP-CLI support is a work in progress and will be improved over time. Feedback welcome!

Requires: 3.0 or higher
Compatible up to: 3.9
Last Updated: 2013-8-4
Downloads: 38,444

Ratings

4 stars
4.9 out of 5 stars

Support

2 of 3 support threads in the last two months have been resolved.

Got something to say? Need help?

Compatibility

+
=
Not enough data

0 people say it works.
0 people say it's broken.

100,1,1
100,1,1
67,3,2
100,2,2
0,1,0
0,3,0
100,1,1
100,1,1
100,1,1
100,1,1
100,1,1
50,2,1
75,4,3
50,2,1
100,1,1
100,3,3
100,1,1
100,5,5 100,2,2
100,3,3 100,1,1 100,1,1
100,1,1
100,2,2
100,1,1
100,1,1 100,3,3