我如何并行执行“for"?在 Bash 中循环? [英] How can I execute parallel "for" loops in Bash?

查看:17
本文介绍了我如何并行执行“for"?在 Bash 中循环?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试并行化以下脚本,特别是 for 循环.我该怎么做?

I have been trying to parallelize the following script, specifically the for loop. How can I do that?

#!/bin/bash
for i in `cat /root/vms`;
do
    /usr/bin/sshpass -p 'test' /usr/bin/ssh -o StrictHostKeyChecking=no 
        -l testuser $i -t 'echo test | sudo -S yum update -y'
done

推荐答案

替换

/usr/bin/sshpass ...

/usr/bin/sshpass ... &

这篇关于我如何并行执行“for"?在 Bash 中循环?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆