ssh同时在多个服务器上

时间:2016-02-19 10:32:07

标签: bash shell ssh

我必须使用shell脚本并行地使用ssh登录各种服务器。 这是一个密码少的身份验证。我必须登录25个服务器并重新启动一个需要花费大量时间的进程。因此,我想同时在所有服务器中执行此过程。我的脚本是这样的:

while read line
do
ssh $line
------restart process-------
done < list.txt &

此处“list.txt”包含服务器列表。我用过“&amp;”为每次迭代调用新shell并为所有服务器重复该过程。但是脚本仍然依次为列表中的服务器执行重启过程。它不会同时执行重启过程。脚本运行的服务器在bash上是bulit,而必须重新启动进程的25个服务器是korn shell上的bulit。任何人都可以告诉我脚本中的错误或使用ssh并行登录是否可行? 提前致谢

2 个答案:

答案 0 :(得分:1)

未经测试,但这应该使用require_once('tmhOAuth/tmhOAuth.php'); //require_once('tmhOAuth/tmhUtilities.php'); $tmhOAuth = new tmhOAuth(array( 'consumer_key' => 'xxxx', 'consumer_secret' => 'xxxx', 'user_token' => 'xxxx', secret' => 'xxxx', )); $tweet_id_str = 'xxxx'; $code = $tmhOAuth->user_request(array( 'method' => 'DELETE', 'url' => $tmhOAuth->url('1.1/statuses/destroy.json'), 'params' => array( 'id' => $tweet_id_str ) )); print "DEBUG: <pre>"; print_r($tmhOAuth->response); print "</pre>"; - 请参阅Wikipedia heredoc

heredoc

答案 1 :(得分:0)

您正在使用主循环,而不是ssh执行尝试使用此

while read line
do
  ssh $line ---restart process--- &
done < list.txt
相关问题