Cron is a UNIX-based tool that schedules tasks on a server. WordPress uses a virtual version of it, known as WP-Cron, to automate internal processes like:
- Publishing scheduled posts
- Sending notification emails
- Checking for updates
- Running backups
These are commonly referred to as cron jobs.
Note:
On 10Web hosting, WP-Cron only runs when your site is visited. When a user loads a page, WordPress checks for due tasks and runs them if needed. This system works well with plugins like WP Crontrol or WP-CLI. However, for low-traffic sites or when heavy cron tasks cause delays, 10Web can activate a real server-side cron.
Important:
This real cron system doesn't integrate with WordPress hooks automatically: you’ll need to request each cron job setup from the 10Web team manually.
This guide covers cron job management using a plugin and the command-line interface WP-CLI.
How to manage WordPress cron jobs with a plugin
Managing cron jobs with a plugin is beginner-friendly. Here, we’ll use WP Crontrol, a free tool that provides all the essential features.
Installing the WP Crontrol plugin
- Go to Plugins → Add New in your WordPress dashboard (or install it from your 10Web dashboard).
- Search for WP Crontrol and install it.
- Once activated, navigate to Tools → Cron Events.
- You’ll see a list of all scheduled events, including:
- Hook names used by the cron
- Next run time
- Recurrence schedule
- PHP action executed
Important:
Do not remove default WordPress cron jobs (those prefixed with wp_). Doing so will break essential functionality.
Adding a new cron event
To create a custom job, let’s schedule a task to delete post revisions and reduce database bloat.
- Open Appearance → Theme File Editor or connect via SFTP/code editor plugin of your choice (like WPCode).
- Access your active theme’s functions.php file.
Add the following code:
add_action( 'cleanup_post_revisions', function() { global $wpdb; $wpdb->query( "DELETE FROM $wpdb->posts WHERE post_type = 'revision'" ); });
- This creates the cleanup_post_revisions hook.
- Go to Tools → Cron Events, then click Add Cron Event.
- Complete the form:
- Hook Name: cleanup_post_revisions
- Arguments: Leave blank
- Next Run: Set to 5–10 minutes from now
- Recurrence: Choose Daily or Weekly
- Click Add Event.
To test it, click Run Now next to the new event.
Edit an existing cron event
- Navigate to Tools → Cron Events.
- Locate and click Edit under the desired event.
- Make your changes to the hook name, arguments, or recurrence.
- Click Update Event.
Important:
Avoid modifying core WordPress events (those starting with wp_)
Managing cron schedules
Under the Cron Schedules tab, you can create custom intervals to use when scheduling tasks. For example, to run a job every 6 hours, create a new schedule with an interval of 21600 seconds.
Note:
All interval times must be entered in seconds.
Accessing and managing your cron jobs via WP-CLI
You have full access to SSH credentials to run WP-CLI commands. You can follow a step-by-step guide on how to connect in a dedicated article. Let’s assume you are already connected and located in the wp-live/ directory of your site. Below are some useful commands for managing your site’s cron events:
List all cron events
wp cron event list - This displays all scheduled tasks, their hook names, next run time, and frequency.
Run a cron event manually
wp cron event run cleanup_post_revisions - Great for verifying if your custom job is working.
Schedule a new cron event
wp cron event schedule cleanup_post_revisions now --repeat --interval=86400
- now: start immediately
- --repeat: make it recurring
- --interval=86400: sets a 24-hour interval
Note:
Make sure your hook is defined in PHP using add_action() in the functions.php file
Delete a scheduled cron event
wp cron event delete cleanup_post_revisions - This removes the scheduled task but keeps the PHP hook.
Run all due events
wp cron event run --due-now - Simulates a site visit to trigger all due cron events.
List available schedules
wp cron schedule list - Use this to view existing time intervals like hourly, daily, or twice daily.