I would like to run dozens of long-running PHP scripts simultaneously, using XAMPP. Each script runs for more than 2 hours and does not use sessions, cookies, etc.
For my first test run, I tried opening up 10 of these scripts on my browser, but only the first six that I opened actually began execution (I know this because at the beginning of each script, I immediately open up a file to write status updates there–nothing gets written from any of the scripts except the first 6).
Is there a code I can put at the top of each script, or some PHP settings I can change, or any other ways I can make it so that I can simultaneously run as many PHP scripts as I want to?
EDIT Here is how to accomplish this:
1) Download PowerShell 2 (or the compatible version with your Windows version) from here: http://support.microsoft.com/kb/968929
2) Install it and restart your computer.
3) Make a new file “example.ps1” and save it to a directory of your choice (e.g. c:\examples\example.ps1). Put this code in that file:
start-job {.\c:\xampp\php\php C:\xampp\htdocs\phpfiles\1.php}
start-job {.\c:\xampp\php\php C:\xampp\htdocs\phpfiles\2.php}
start-job {.\c:\xampp\php\php C:\xampp\htdocs\phpfiles\3.php}
start-job {.\c:\xampp\php\php C:\xampp\htdocs\phpfiles\4.php}
start-job {.\c:\xampp\php\php C:\xampp\htdocs\phpfiles\5.php}
start-job {.\c:\xampp\php\php C:\xampp\htdocs\phpfiles\6.php}
start-job {.\c:\xampp\php\php C:\xampp\htdocs\phpfiles\7.php}
start-job {.\c:\xampp\php\php C:\xampp\htdocs\phpfiles\8.php}
start-job {.\c:\xampp\php\php C:\xampp\htdocs\phpfiles\9.php}
start-job {.\c:\xampp\php\php C:\xampp\htdocs\phpfiles\10.php}
start-job {.\c:\xampp\php\php C:\xampp\htdocs\phpfiles\11.php}
4) Click on “Start” -> “Run” and type in “powershell” (without quotes).
5) After PowerShell initiates, type in the following and press enter:
Set-ExecutionPolicy RemoteSigned
Then press “y” to set the changes.
6) Now type in (make sure to enter in the full file path):
c:\examples\example.ps1
7) To see your jobs simply type in:
get-job
To stop a job use this command:
stop-job JobName
Browsers will block simultaneous connections. Use command line and you also will have less issues with timeouts. Plus output is instant so you can echo all the time.