How to debug WordPress “Cron” wp_schedule_event

How can I debug problems with WordPress Cron? I think it will trigger when users go to your site but any errors wont be shown to them, as the jobs are run “asynchronously”. So how might I debug errors?

I use wp schedule event


You can run WP cron manually by calling:

If you don’t want the automatic cron to run while you’re debugging, then add this to your /wp-config.php file:

define('DISABLE_WP_CRON', true);

If you’re on a development environment and want to output debug information, calling it manually like that will show you your debug output.

Alternatively you can use PHP’s built-in error_log function to log message strings to the error log for debugging. You’d need to use this in conjunction with WP_DEBUG settings, as mentioned by Rarst.

Leave a Comment