On Mon, 20 Sep 2004 16:36:51 +0100, John Wards <[EMAIL PROTECTED]> wrote:
> Right I have a script that I need to run around 90 times thru a cron job
> but passing a different i.d. to it each time.
> 
> I have experimented with running all 90 at once and its a no go as it
> just makes the server run to slow and the session cookies I use time out
> (I am doing some libcurl things).
> 
> Also running them in a loop one at a time is no use because it takes
> about 8 hours.
> 
> What I would like to do is fork off say 5-10 at a time and when one is
> done start another one in its place, as they all take different length
> of times to compleate.
> 
> Any clues at where to start? Here is my fork all 90+ code...
> 
> $sql = "SELECT * FROM locations WHERE parent = '0'";
> $res = mysql_query($sql) or die ($sql.mysql_error());
> while($data = mysql_fetch_array($res)){
>         exec("/usr/local/bin/php fork.php ".$_data["id"]." > /dev/null &");

I'd write a scheduler.  Insert the jobs into the database whenever
they need to run.  Then have a script that runs via cron that will
monitor system load, and start and stop jobs as required.

http://pear.php.net/package/System_ProcWatch


-- 
Greg Donald
http://gdconsultants.com/
http://destiney.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to