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

查看:60
本文介绍了我如何执行并行的"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天全站免登陆