<br><div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">I am not sure I understand the problem.<br>If you want to make sure only one process runs at a time, we can use a locking
<br>mechanism like I do in one module:<br><br>Making sure we get the lock prevents a race condition, a problem that make<br>poormanscron.module currently unuseable (see link in code comment).<br><br>/**<br> * Implementation of hook_cron().
<br> */<br>function hook_cron() {<br>&nbsp;&nbsp;// Check if we have another instance of cron running.<br>&nbsp;&nbsp;if (variable_get(&#39;hook_cron_running&#39;, 0)) {<br>&nbsp;&nbsp;&nbsp;&nbsp;return;<br>&nbsp;&nbsp;}<br>&nbsp;&nbsp;// hook_cron is not already running.<br>&nbsp;&nbsp;// See if we can get the lock before another process does.
<br>&nbsp;&nbsp;// Algorithm found here: <a href="http://drupal.org/node/43511">http://drupal.org/node/43511</a>.<br>&nbsp;&nbsp;$result = db_query(&quot;UPDATE {variable} SET value = &#39;i:1;&#39; WHERE name =<br>&#39;hook_cron_running&#39; AND value = &#39;i:0;&#39;&quot;);
<br>&nbsp;&nbsp;if (db_affected_rows() != 1) {<br>&nbsp;&nbsp;&nbsp;&nbsp;// We didn&#39;t get the lock. Another process outran us.<br>&nbsp;&nbsp;&nbsp;&nbsp;watchdog(&#39;hook_cron&#39;, &#39;This cron process was outraced.&#39;);<br>&nbsp;&nbsp;&nbsp;&nbsp;return;<br>&nbsp;&nbsp;}<br>&nbsp;&nbsp;// Do stuff here...
<br><br>&nbsp;&nbsp;// then, at the end:<br>&nbsp;&nbsp;// Unlock.<br>&nbsp;&nbsp;variable_set(&#39;hook_cron_running&#39;, 0);<br>&nbsp;&nbsp;return;<br>}<br></blockquote></div><br>Wouldn&#39;t the second process be blocked until the first one completes, instead
<br>of returning immediately? There is no equivalent to Oracle&#39;s NOWAIT in MySQL<br>as far as I recall.<br>-- <br><a href="http://2bits.com">2bits.com</a><br><a href="http://2bits.com">http://2bits.com</a><br>Drupal development, customization and consulting.