How can I simultaneously run dozens of PHP scripts in the background from XAMPP's command line interface?
Someone suggested a batch file, but when I tried executing this:
start php 1.php
start php 2.php
start php 3.php
It only opened a command prompt window; I closed that window, then two more command prompt windows opened up executing 2.php and 3.php.
I want to run as many scripts as I want all simultaneously and all in the background. What is the best way to accomplish this, and how can it be done?
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