Page 1 of 1

Running multiple instances of a PHP script

Posted: Fri Aug 19, 2005 3:00 pm
by anjanesh
Hi

I have a script - run.php which does some long running task - this takes hours to complete.

I tried to open a new window with run.php but it doesnt seem to start until the other one is finished. Instead - if I make a copy of it say run1.php it works fine - obviously - because they are 2 different scripts. But the code reads/writes data to a MySQL database which takes places once in a few mins - the mysql access part is not resource intensive.

Is there any way for me to get run.php running simultaneously in say 10 browser windows ?
Not running on this localhost - running this on the server - in the form of a url.

Thanks

Posted: Fri Aug 19, 2005 3:09 pm
by protokol
Does this script simply process data in the background and not actually display anything on the web page? If so, then you might considure the Process Control Functions.

http://www.php.net/pcntl

They are a nice way to fork processes to handle multiple tasks simultaneously.

Posted: Fri Aug 19, 2005 9:57 pm
by anjanesh
Well...it doesnt really need to display anything - but I've given an echo statement in the loop so that I can see the progress.
If I didnt want it to display anything then I would've set it in cron.