多主機下同一命令 - Linux

Table of Contents


多主機下同一命令

有一強者寫了個叫 dssh 的shell script


http://bashcurescancer.com/dssh-executing-an-arbitrary-command-in-parallel-on-an-arb
itrary-number-of-hosts.html


不過我認為下面這樣比較簡單
缺點是不能有其它參數,等我會寫之後再改進好了
------------------- 指令
list='virtue@::1 [email protected]'
dssh(){ for i in $list;do echo $i\:;ssh $i $1;done;}
dssh uptime
------------------- 結果
virtue@::1:
21:33:43 up 23:03, 0 users, load average: 0.54, 0.42, 0.64
[email protected]:
9:36PM up 8 days, 8:58, 0 users, load averages: 2.00, 2.02, 2.00

--

All Comments

Sarah avatarSarah2010-02-15
用 omnitty 或是 pdsh 也是個方法
Mary avatarMary2010-02-19
期待您的作品