wp-cron.php – How are WP’s Cron transients removed?

I have a WordPress Network that I am tasked with disabling the WP Cron and replacing it with an Apache Cron. I have set up a PHP script that when called by an Apache Cron will loop through all sites under the network and make a request to that site’s wp-cron.php page, thus executing its cron.

I would like to use WordPress’ transient feature to limit my PHP script as WordPress limits its own cron. However, when I dig into the code I see the doing_cron transient is set ( in cron.php #217 ) but never unset.

Read More

Is the transient ever unset or does WordPress wait 60 seconds to fire up the cron again ( in cron.php #200 )

Any thoughts on the doing_cron transient or perhaps another means to throttle my cron script would be appreciated.

Related posts

Leave a Reply

2 comments

  1. Transients expire on their own. No need to unset them.

    And to call wp-cron manually is simple. Just define DISABLE_WP_CRON to true in the wp-config file to disable the normal cron spawning process. Then make your cron system hit wp-cron.php manually every so often to process pending jobs.

    There is no other special trick that you need to do. No need to fool around with transients or special coding.

  2. cron.php#195

    $flag = get_transient('doing_cron');
    

    If transient is past expiration time then during this call it will be unset and false returned.

    I usually rely on wp cron, so have no experience to advise you on handling this (for multisite on top).