运维服务器需要把log拷到本地分析, 逐条scp太慢,希望并行执行。
对于时序没有严格要求的命令, 使用&将每条指令后台运行, 无需等待上条结束继续执行下条。 最后配合wait等待全部执行完毕
#!/bin/bash for host in server{0..35} do ( scp user@$host:/tmp/log*.tar.gz ~/logs/ )& done wait