shell进程的并行执行 [英] Parallel execution of shell processes
问题描述
是否有可以在 Windows 批处理文件中并行执行多个进程的工具?我发现了一些有趣的 Linux 工具(parallel 和 PPSS),但是,我需要一个适用于 Windows 平台的工具.
Is there a tool available to execute several process in parallel in a Windows batch file? I have found some interesting tools for Linux (parallel and PPSS), however, I would need a tool for Windows platforms.
奖励:如果该工具还允许以简单的方式在多台机器之间分配进程,远程运行进程,那就太好了PsExec.
Bonus: It would be great if the tool also allowed to distribute processes in an easy way among several machines, running the processes remotely a la PsExec.
示例:我希望在下面的 for 循环中使用
Example: I would like that in the following for loop
for %F in (*.*) do processFile.exe %F
并行运行数量有限的 processFile.exe 实例以利用多核 CPU.
a limited amount of instances of processFile.exe are running in parallel to take advantage of multi-core CPUs.
推荐答案
Linux 下的 GNU xargs 有一个-P n"开关可以并行启动n"个进程.
GNU xargs under Linux has a "-P n" switch to launch "n" processes in parallel.
也许 cygwin/mingw 构建的 xargs 也支持这个?
Maybe cygwin/mingw build of xargs also supports this?
然后你可以使用:
xargs -P 4 processFile < fileList
不过,不会产生花哨的多节点进程.
No fancy multi-node process spawning, though.
这篇关于shell进程的并行执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!