参数:
# pssh
Usage: pssh [OPTIONS] -h hosts.txt prog [arg0] ..
-h --hosts hosts file (each line "host[:port] [user]")
-l --user username (OPTIONAL)
-p --par max number of parallel threads (OPTIONAL)
-o --outdir output directory for stdout files (OPTIONAL)
-t --timeout timeout in seconds to do ssh to a host (OPTIONAL)
-v --verbose turn on warning and diagnostic messages (OPTIONAL)
-O --options SSH options (OPTIONAL)
Example: pssh -h ips.txt -l irb2 -o /tmp/foo uptime
例子:
以下示例使用login irb2在文件ips.txt中指定的三台计算机(IP或主机名)上运行主机名,并将输出保存在/ tmp / foo中。
# cat ips.txt
128.112.152.122
18.31.0.190
128.232.103.201
# pssh -h ips.txt -l irb2 -o /tmp/foo hostname
Success on 128.112.152.122:22
Success on 18.31.0.190:22
Success on 128.232.103.201:22
# ls /tmp/foo
128.112.152.122 128.232.103.201 18.31.0.190
# cat /tmp/foo/*
planetlab-1.cs.princeton.edu
planetlab1.xeno.cl.cam.ac.uk
planetlab1.lcs.mit.edu
默认情况下,pssh与ssh平行使用最多32个ssh进程到各个节点。 (这对于控制数百台或几千台机器来说有些重要。)默认情况下,它还使用一秒钟的时间到ssh到一个节点,并获得一个结果。 对于比这更长的ssh命令(例如睡眠61),可以使用-t选项。 请注意,pssh和pnuke的默认超时时间为1分钟。 pscp和prsync没有默认超时,但可以使用-t选项指定一个。
环境变量:
PSSH_HOSTS
PSSH_USER
PSSH_PAR
PSSH_OUTDIR
PSSH_VERBOSE
PSSH_OPTIONS
以下是一些实例设置:
#export PSSH_HOSTS=”/x/bnc/ips.txt”
# export PSSH_USER=”irb2”
# export PSSH_PAR=”32”
# export PSSH_OUTDIR=”/tmp/bar”
# export PSSH_VERBOSE=”0”
# export PSSH_OPTIONS=”UserKnownHostsFile /tmp/known_hosts”
使用上述设置,可以简单执行示例:
# pssh hostname
Success on 128.112.152.122:22
Success on 18.31.0.190:22
Success on 128.232.103.201:22
# ls /tmp/bar
128.112.152.122 128.232.103.201 18.31.0.190
# cat /tmp/bar/*
planetlab-1.cs.princeton.edu
planetlab1.xeno.cl.cam.ac.uk
planetlab1.lcs.mit.edu
# pscp /etc/hosts /tmp/hosts
Success on 128.112.152.122:22
Success on 18.31.0.190:22
Success on 128.232.103.201:22
# pnuke java
Success on 128.112.152.122:22
Success on 18.31.0.190:22
Success on 128.232.103.201:22
译自:http://www.theether.org/pssh/docs/0.2.3/pssh-HOWTO.html#AEN40