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.

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.


2 Answers 2


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.

  • Agreed, I only thought of using transients because my php script will cycle through all sites under a network and call each site’s individual wp-cron.php. My reasoning being that if I call an apache Cron to hit my php script every minute and for some reason the php script has not finished running through all sites yet I would like to use the same transient system that Wordpress uses to disable my php script if it is already running. I could just copy the functionality from spawn_cron() as is but I am not sure if I would be missing any part of the transient system? Jan 21, 2011 at 0:54


$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).

  • Okay, in the function spawn_cron() the expiration time is not set and is therefore defaulted to 0. So, a Wordpress cron will not be allowed to run at the exact same time as another but could run a second or later because the transient has already expired. I probably just need to set a transient’s expiration time to an acceptable time/frequency or not use them at all as Otto mentioned because my apache cron should never be called more than once at any one time. Jan 21, 2011 at 1:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.