WordPress.org

Ready to get started?Download WordPress

Forums

WP-CRON : wp_next_scheduled() returning a passed timestamp (4 posts)

  1. Ben
    Member
    Posted 2 years ago #

    Hi there,

    This is not the first time I see that issue on one of my client site.
    It happened earlier with some clients using WP 3.2.1, I told them to update to the latest version of WP and then it was working again somehow.

    Unfortunately my current client is already using the latest version of WP. So I'm not sure what to tell him. :)

    I don't have any idea why once the first scheduled time is passed a new one is not incremented. Also it seems like the function is not called at trigger time.

    I have read somewhere that this could be because of an overloaded server, though this server seems to be running perfectly fine.

    So I'm not sure what to do. I will debug WP functions until I get a hint, yet if someone here has any idea why is this occurring I would be happy to hear it :)

    Cheers,
    Ben

  2. Ben
    Member
    Posted 2 years ago #

    Hey,
    Here are some screenshots I took of our plugin wysija-newsletters, it is showing a listing of campaigns. Basically we use the next scheduled time returned by WordPress to calculate when will be sent the next batch of emails stored in the queue.

    Somehow while debugging the cron the wp_next_scheduled() function started to work again as shown in that screenshot:
    http://bencaubere.com/bugs_wp_cron/cron_is_back_on_schedule.JPG

    So I thought to myself. That's it ! It's working again !

    But then once the scheduled time was past, no new emails were sent and the wp_next_scheduled() didn't increment again, see screenshot:
    http://bencaubere.com/bugs_wp_cron/cron_is_out_of_schedule_again.JPG

    So I don't know what to do. Once again I'm lost with that process. Do you think it is because the server is overloaded ? I don't see how's that happenning.

    Anyway if anyone has any clue, please share your idea.

    Cheers,
    Ben

  3. bcworkz
    Member
    Posted 2 years ago #

    I don't know if the following has anything to do with your problem, but it may be something to consider.

    WP-Cron is not a true cron job. Someone has to visit the site to trigger a scheduled event. All scheduled events whose scheduled times have passed are processed when someone visits. I can imagine a situation where wp_next_scheduled() is called before the scheduled events are processed, so it will return a passed timestamp.

  4. Ben
    Member
    Posted 2 years ago #

    Hi bcworkz,

    Thanks for your answer. Actually this client is one of our premium client and so we trigger automatically his site every 15min from our own server, it works perfectly with all of our other clients. Unfortunately it seems sometimes the wp-cron can be failing somehow.

    Anyway I found some sort of a workaround, I'm using the plugin :
    http://wordpress.org/extend/plugins/wp-cron-control/ by Automattic which helps in that situation. I'm not sure why don't they include it in the core version of WP though.

    And in that particular case it is a lifesaver.

    Ben

Topic Closed

This topic has been closed to new replies.

About this Topic