Since PHP does one thing at the time, for a similar task (pinging) I created a batch script that calls multiple php jobs using arguments.
So the loop is in the batch file. This also distributes the load on multiple CPUs, since jobs are spread. The batch read information for scanning from a CVS file that has 10 items per row (to run 10 processes at the time).
It is running on a windows server, but same can be applied on any.
here is the content of my batch file as an example:
@Echo Off
For /F "usebackq tokens=1-10 delims=," %%a in ("D:\php_run\all_locations_10.cvs") Do (
echo Scanning: %%a
start "Scanning %%a" "C:\Program Files (x86)\PHP\v5.3\php.exe" "-f" "D:\php_run\wkstn_scan.php" "%%a"
echo Scanning: %%b
start "Scanning %%b" "C:\Program Files (x86)\PHP\v5.3\php.exe" "-f" "D:\php_run\wkstn_scan.php" "%%b"
echo Scanning: %%c
start "Scanning %%c" "C:\Program Files (x86)\PHP\v5.3\php.exe" "-f" "D:\php_run\wkstn_scan.php" "%%c"
echo Scanning: %%d
start "Scanning %%d" "C:\Program Files (x86)\PHP\v5.3\php.exe" "-f" "D:\php_run\wkstn_scan.php" "%%d"
echo Scanning: %%e
start "Scanning %%e" "C:\Program Files (x86)\PHP\v5.3\php.exe" "-f" "D:\php_run\wkstn_scan.php" "%%e"
echo Scanning: %%f
start "Scanning %%f" "C:\Program Files (x86)\PHP\v5.3\php.exe" "-f" "D:\php_run\wkstn_scan.php" "%%f"
echo Scanning: %%g
start "Scanning %%g" "C:\Program Files (x86)\PHP\v5.3\php.exe" "-f" "D:\php_run\wkstn_scan.php" "%%g"
echo Scanning: %%h
start "Scanning %%h" "C:\Program Files (x86)\PHP\v5.3\php.exe" "-f" "D:\php_run\wkstn_scan.php" "%%h"
echo Scanning: %%i
start "Scanning %%i" "C:\Program Files (x86)\PHP\v5.3\php.exe" "-f" "D:\php_run\wkstn_scan.php" "%%i"
echo Scanning: %%j
start /WAIT "Scanning %%j" "C:\Program Files (x86)\PHP\v5.3\php.exe" "-f" "D:\php_run\wkstn_scan.php" "%%j"
)