Title: Debugging cron tasks
Last modified: August 19, 2016

---

# Debugging cron tasks

 *  [JohnnyPea](https://wordpress.org/support/users/johnnypea/)
 * (@johnnypea)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/debugging-cron-tasks/)
 * How could I debug cron task run by internal [cron functions](http://codex.wordpress.org/Category:WP-Cron_Functions)?
   My cron task is not firing and I suppose some functions are not declared yet 
   when cron hook takes place.
 * It would be great if I can store the errors into some log file? Any ideas? Thanks.
 * I used [Core Control](http://wordpress.org/extend/plugins/core-control/) plugin
   to see if everything is all right. The _my\_task\_hook_ and hooked function too,
   the “due time” is changing…so something else must be wrong.

Viewing 1 replies (of 1 total)

 *  Thread Starter [JohnnyPea](https://wordpress.org/support/users/johnnypea/)
 * (@johnnypea)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/debugging-cron-tasks/#post-1807982)
 * I am using the functions `category_exists` and `post_exists` which are declared
   for “wp-admin” only. This was the problem.
 * I found out the easiest way to debug cron in WordPress is add your function to
   this hook: `add_action( 'sanitize_comment_cookies', 'your_cron_function' );` 
   because `wp_cron` function is also executed in this action hook. You will see
   errors outputted (if there are any) after doing this when you reload your front-
   end page.

Viewing 1 replies (of 1 total)

The topic ‘Debugging cron tasks’ is closed to new replies.

## Tags

 * [cron](https://wordpress.org/support/topic-tag/cron/)
 * [debugging](https://wordpress.org/support/topic-tag/debugging/)
 * [log](https://wordpress.org/support/topic-tag/log/)
 * [logging](https://wordpress.org/support/topic-tag/logging/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: [JohnnyPea](https://wordpress.org/support/users/johnnypea/)
 * Last activity: [15 years, 6 months ago](https://wordpress.org/support/topic/debugging-cron-tasks/#post-1807982)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
