You might want to think about queue, which has been backported to D6. Here are rough notes from John VanDyk's drupalcon sf preso on batch v. queue:<div><br></div><div><p style="margin:0.0px 0.0px 0.0px 0.0px;font:12.0px Helvetica">
//</p><p style="margin:0.0px 0.0px 0.0px 0.0px;font:12.0px Helvetica">when to use batch:</p>
<p style="margin:0.0px 0.0px 0.0px 0.0px;font:12.0px Helvetica"> - when you're doing something that will exceed php's time-out</p>
<p style="margin:0.0px 0.0px 0.0px 0.0px;font:12.0px Helvetica"> - when you're writing something that could get large</p>
<p style="margin:0.0px 0.0px 0.0px 0.0px;font:12.0px Helvetica"> - when you want to give users feedback on what's going on</p>
<p style="margin:0.0px 0.0px 0.0px 0.0px;font:12.0px Helvetica;min-height:14.0px"><br></p>
<p style="margin:0.0px 0.0px 0.0px 0.0px;font:12.0px Helvetica">when to use queue</p>
<p style="margin:0.0px 0.0px 0.0px 0.0px;font:12.0px Helvetica"> - when you want to stash things for later processing</p>
<p style="margin:0.0px 0.0px 0.0px 0.0px;font:12.0px Helvetica"> - when you want to distribute computing</p>
<p style="margin:0.0px 0.0px 0.0px 0.0px;font:12.0px Helvetica"> - when you want to run queue "with a twist" (conditional outputs, other processes kicked off, etc)</p>
<p style="margin:0.0px 0.0px 0.0px 0.0px;font:12.0px Helvetica;min-height:14.0px">//</p><p style="margin:0.0px 0.0px 0.0px 0.0px;font:12.0px Helvetica;min-height:14.0px"><br></p><p style="margin:0.0px 0.0px 0.0px 0.0px;font:12.0px Helvetica;min-height:14.0px">
...not that those were particularly useful to your question, but they're a basis. <span class="Apple-style-span" style="font-family: arial; font-size: small; ">There are some details instructions in drupal_queue.module's readme.txt (the backport from D7) that will help you decide whether running a queue under a separate crontab (or even using drush) makes sense. If I were in your position, I'd lean heavily in that direction not only for the "offswitch", but for the option of distributing that computing down the road, which is possible with queue.</span></p>
<div><br></div><div>regards/BF</div><div><br></div><div><br></div><div><br></div><div class="gmail_quote">
On Mon, May 10, 2010 at 9:02 AM, Leo Burd <span dir="ltr"><<a href="mailto:leob@media.mit.edu" target="_blank">leob@media.mit.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello there,<br>
<br>
Is there any way to start/stop background processes from inside Drupal?<br>
<br>
I'm currently writing a module that has to continuously monitor a socket connection for events coming from a remote server. I thought about using hook_cron(), but I'm afraid that the infinite (or continuous) loop of my event handler would tie out other modules that use hook_cron(). Another alternative would be to use batch api, but do batch processes run in the background?<br>
<br>
Thanks in advance,<br><font color="#888888">
<br>
Leo<br>
</font></blockquote></div><br></div>