WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
It seems they are not handled by cron. Rarst wrote about this here: wordpress.stackexchange.com/questions/6602/… – onetrickpony Jan 15 '11 at 0:53
@Ambitious Amoeba nope, this is different from my question – Rarst Jan 15 '11 at 13:49
up vote 5 down vote accepted

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.

share|improve this answer
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? – Jonnybojangles Jan 21 '11 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).

share|improve this answer
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. – Jonnybojangles Jan 21 '11 at 1:03

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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