设为首页 - 加入收藏 ASP站长网(Aspzz.Cn)- 科技、建站、经验、云计算、5G、大数据,站长网!
热搜: 创业者 手机 数据
当前位置: 首页 > 服务器 > 搭建环境 > Linux > 正文

批量执行工具PSSH详解(2)

发布时间:2021-01-21 15:31 所属栏目:118 来源:网络整理
导读:-L:指定从远程主机拷贝文件放置的目录,拷贝/root/expect.sh文件,并将其重命名为test1. 如果拷贝目录需要使用-r参数: [root@localhost ~]# pslurp -h /etc/pssh_hosts -L /tmp/ /root/expect.sh test1 [1] 10:44:

-L:指定从远程主机拷贝文件放置的目录,拷贝/root/expect.sh文件,并将其重命名为test1.
如果拷贝目录需要使用-r参数:

[root@localhost ~]# pslurp -h /etc/pssh_hosts -L /tmp/ /root/expect.sh test1 
[1] 10:44:55 [FAILURE] web1.jiajie.com 22 Received error code of 1
[2] 10:44:56 [FAILURE] web3.jiajie.com 22 Received error code of 1
[3] 10:44:56 [SUCCESS] web2.jiajie.com 22
[root@localhost ~]# ll /tmp/web2.jiajie.com/
总用量 4
-rw-r--r-- 1 root root 139 10月 17 10:44 test1

[root@localhost ~]# pslurp -r -h /etc/pssh_hosts -L /tmp/ /root/shell.sh test2


<h3 id="prsync-命令">prsync 命令:

Usage: prsync [OPTIONS] -h hosts.txt local remote

-r --recursive recusively copy directories (OPTIONAL)
-a --archive use rsync -a (archive mode) (OPTIONAL)
-z --compress use rsync compression (OPTIONAL)
-h --hosts hosts file (each line "host[:port] [login]")
-l --user username (OPTIONAL)
-p --par max number of parallel threads (OPTIONAL)
-o --outdir output directory for stdout files (OPTIONAL)
-e --errdir output directory for stderr files (OPTIONAL)
-t --timeout timeout (secs) (-1 = no timeout) per host (OPTIONAL)
-v --verbose turn on warning and diagnostic messages (OPTIONAL)
-O --options SSH options (OPTIONAL)

Example: prsync -r -h hosts.txt -l irb2 foo /home/irb2/foo

prsync的主要作用是通过rsync协议将文件或目录从本地主
机同步到远程多个主机上。

[root@localhost ~]# prsync -h /etc/pssh_hosts -a -r /root/shell.sh /tmp
[1] 11:33:26 [SUCCESS] web3.jiajie.com 22
[2] 11:33:26 [SUCCESS] web1.jiajie.com 22
[3] 11:33:27 [SUCCESS] web2.jiajie.com 22

-r:递归复制。

-a:保持文件的属性不变

-z:压缩文件,一般不推荐。

Usage: pnuke [OPTIONS] -h hosts.txt pattern

-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)
-e --errdir output directory for stderr files (OPTIONAL)
-t --timeout timeout (secs) (-1 = no timeout) per host (OPTIONAL)
-v --verbose turn on warning and diagnostic messages (OPTIONAL)
-O --options SSH options (OPTIONAL)

Example: pnuke -h hosts.txt -l irb2 java

pnuke的主要作用是在远程多主机上并行杀掉某一进程,
相当于killall命令。可以直接使用pssh 来传递killall命令,这里就不做介绍了。

(编辑:ASP站长网)

网友评论
推荐文章
    热点阅读