Linux concurrent execution is simple and that's it
- 2020-11-30 08:46:08
- OfStack
&
Concurrency features of
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
Concurrency features of 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
Concurrency is pretty simple, no need for golang or python's 10 lines of code, no need to install the environment, compile and so on, just go back to basics.