This article covers how to troubleshoot WP-Cron issues with WP-CLI. This will help you determine if the WP-Cron jobs are running. This is applicable across all server types.
Related Article
Enable/Configure Debugging for WordPress
Troubleshoot Issues
NOTE: It may be feasible to set up regular cron jobs instead of wp-cron.
- SSH into the server as the cPanel user
cd
into the Document Root for their site
cd $(docroot.py domain.com)
REPLACE: domain.com with the relevant domain.- List all wp-crons with
wp cron event list
EXAMPLE:
[user@hostname public_html]$ wp cron event list
+------------------------------------+---------------------+-----------------------+---------------+
| hook | next_run_gmt | next_run_relative | recurrence |
+------------------------------------+---------------------+-----------------------+---------------+
| action_scheduler_run_queue | 2020-06-17 18:40:16 | 18 seconds | 1 minute |
| jetpack_sync_full_cron | 2020-06-17 18:42:14 | 2 minutes 16 seconds | 5 minutes |
| jetpack_sync_cron | 2020-06-17 18:42:38 | 2 minutes 40 seconds | 5 minutes |
| job_manager_check_for_expired_jobs | 2020-06-17 18:47:11 | 7 minutes 13 seconds | 1 hour |
| jetpack_backup_cleanup_helper_scri | 2020-06-17 19:00:35 | 20 minutes 37 seconds | Non-repeating |
| pts | | | |
| wp_privacy_delete_old_export_files | 2020-06-17 19:01:08 | 21 minutes 10 seconds | 1 hour |
| cleanUpOldLog | 2020-06-17 19:11:54 | 31 minutes 56 seconds | 1 hour |
| nxs_hourly_event | 2020-06-17 19:13:29 | 33 minutes 31 seconds | 1 hour |
..... - Test all wp-crons with
wp cron test
EXAMPLE:
[user@hostname public_html]$ wp cron test
Warning: The ALTERNATE_WP_CRON constant is set to true. WP-Cron spawning is not asynchronous.
Success: WP-Cron spawning is working as expected.NOTE: If wp-cron isn't working you might see something like this:
[user@hostname public_html]$ wp cron test
Error: The DISABLE_WP_CRON constant is set to true. WP-Cron spawning is disabled. - If you received an error similar to the example in step 4, open the wp-config.php file in your favorite text editor and change the
DISABLE_WP_CRON
fromtrue
tofalse
or add theDISABLE_WP_CRON
line if needed, and set the value tofalse
EXAMPLE:
/** Enable W3 Total Cache Edge Mode */
define('W3TC_EDGE_MODE', true); // Added by W3 Total Cache
define('WP_MEMORY_LIMIT', '256m');
define('DISABLE_WP_CRON', true); // <--change this to 'false'
/** - Test a single wp-cron job
wp cron event run <hook>
TIP: Where <hook> is the actual name of the job being tested, see table in step 3 for examples of hooks.[user@hostname public_html]$ wp cron event run check_application_deadlines
Executed the cron event 'check_application_deadlines' in 0.004s.
Success: Executed a total of 1 cron event. - Look at the wp-cron schedule run
wp cron schedule list
EXAMPLE:
[user@hostname public_html]$ wp cron schedule list
+--------------------------------------+---------------------+----------+
| name | display | interval |
+--------------------------------------+---------------------+----------+
| every_minute | Every minute | 60 |
| wphb_cache_preload_cron_interval | Every 5 Minutes | 300 |
| jetpack_sync_interval | Every 5 minutes | 300 |
| everyhour | Every hour | 3600 |
| hourly | Once Hourly | 3600 |
..... - If no errors are noted in any of the above steps, turn on debugging in WordPress and monitor error logs for wp-cron errors
TIP: For more things you can do withwp cron
in WP-CLI Runwp help cron
for help.
For the full Documentation on the wp cron command, view the documentation.
Comments
0 comments
Article is closed for comments.