bash脚本提交后台运行
For example, I want to spawn many ssh background processes in one bash script:
for i in `cat ./all-hosts`
do
ssh $i "ifconfig | grep Link"
done
Simply adding a & to the ssh commands does not work.
只是在ssh命令中添加&无效。
Here is the script that works:
这是起作用的脚本:
for i in `cat ./all-hosts`
do
ssh $i "ifconfig | grep Link" &
done
Or in one comman

本文介绍了如何在Bash脚本中正确地创建并行运行的后台进程。通过使用子shell(&)来启动ssh命令,可以实现多个进程在后台同时运行。并且,当需要等待所有后台进程结束后再进行下一步时,可以使用wait命令。
最低0.47元/天 解锁文章
1367

被折叠的 条评论
为什么被折叠?



