WordPress.org

Ready to get started?Download WordPress

Forums

Debugging cron tasks (2 posts)

  1. JohnnyPea
    Member
    Posted 3 years ago #

    How could I debug cron task run by internal 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 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.

  2. JohnnyPea
    Member
    Posted 3 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic