时间:2020-10-09 13:09:45 | 栏目:Linux | 点击:次
&的并发功能
time for i in `grep server /etc/hosts | awk '{print $1}'`; do (ssh $i "echo 123; sleep 1; echo 456" &); done real 0m0.063s user 0m0.016s sys 0m0.004s
xargs的并发功能
time grep server /etc/hosts | awk '{print $1}' | xargs -P 24 -I {} ssh {} "echo 123; sleep 1; echo 456" real 0m3.747s user 0m1.136s sys 0m0.112s
并发其实很简单,不需要golang或者python的几十行代码,不需要安装环境,编译等等繁琐的步骤,返朴归真就对了。