由于 PHP 当时只做一件事,对于类似的任务(pinging),我创建了一个批处理脚本,该脚本使用参数调用多个 php 作业。
所以循环在批处理文件中。这也将负载分布在多个 CPU 上,因为作业是分散的。用于从 CVS 文件中扫描的批处理读取信息,该文件每行有 10 个项目(一次运行 10 个进程)。
它在 Windows 服务器上运行,但同样适用于任何服务器。
这是我的批处理文件的内容作为示例:
@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 扫描:%%c
start "扫描%% c" "C:\Program Files (x86)\PHP\v5.3\php.exe" "-f" "D:\php_run\wkstn_scan.php" "%%c"
echo 扫描:%%d
start "扫描%%d" "C:\Program Files (x86)\PHP\v5.3\php.exe" "-f" "D:\php_run\wkstn_scan.php" "%%d"
echo 扫描: %%e
start "扫描%%e" "C:\Program Files (x86)\PHP\v5.3\php.exe" "-f" " D:\php_run\wkstn_scan.php" "%%e"
echo 扫描:%%f
start "扫描 %%f" "C:\Program Files (x86)\PHP\v5.3\php.exe" "-f" "D:\php_run\wkstn_scan.php" "%% f"
echo 扫描:%%g
start "扫描%%g" "C:\Program Files (x86)\PHP\v5.3\php.exe" "-f" "D:\php_run\wkstn_scan.php" " %%g"
echo 扫描:%%h
start "扫描%%h" "C:\Program Files (x86)\PHP\v5.3\php.exe" "-f" "D:\php_run\wkstn_scan.php " "%%h"
echo 扫描: %%i
start "扫描%%i" "C:\Program Files (x86)\PHP\v5.3\php.exe" "-f" "D:\php_run\wkstn_scan .php" "%%i"
echo 扫描: %%j
start /WAIT "扫描 %%j" "C:\Program Files (x86)\PHP\v5.3\php.exe" "-f" "D:\php_run\wkstn_scan.php" "%%j"
)