shell脚本自动化收集
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了shell脚本自动化收集相关的知识,希望对你有一定的参考价值。
将某文件远程拷贝到指定ip机器上的指定目录下:
./scp_file.sh /tmp/xx.sh /tmp/test/
echo "将文件 $1 拷贝到 $2 目录下!" for ip in 192.168.60.243 192.168.60.244 192.168.60.245 192.168.60.246 192.168.60.248 do scp -r $1 [email protected]$ip:$2 echo "scp $1 to $ip is : $? " done echo "$? 分发完毕!!"
远程执行指定ip机器上的指定shell文件命令(需要ssh支持)(可带参数):
./execute.sh /tmp/xx.sh xx
for ip in 192.168.60.243 192.168.60.244 192.168.60.245 192.168.60.246 192.168.60.248 do ssh [email protected]$ip $1 $2 echo "execute $1 $2 at $ip is : $? " done echo "$? $1执行完毕!"
copy-hosts.sh
#!/bin/bash cp /opt/tmp/hosts.txt /opt/tmp/hosts.txt.bak echo "$? copy finish!" exit 0
append-ssh.sh
#!/bin/bash cat /opt/tmp/ssh.txt >> /root/.ssh/authorized_keys echo "$? append ssh finish!" exit 0
rmtest.sh
#!/bin/bash rm -rf $1 echo "$? rm finish!" exit 0
install-hadoop-hbase.sh
#!/bin/bash cp /opt/tmp/hadoop-2.5.1.tar.gz /opt/hadoop-2.5.1.tar.gz cp /opt/tmp/hbase-0.98.7-hadoop2-bin.tar.gz /opt/hbase-0.98.7-hadoop2-bin.tar.gz echo "$? copy finish!" cd /opt/ tar xvf hbase-0.98.7-hadoop2-bin.tar.gz echo "$? install hbase finish!" tar xvf hadoop-2.5.1.tar.gz echo "$? install hadoop finish!" exit 0
install-jdk.sh
#!/bin/bash mkdir -p /usr/java/ cp /opt/tmp/jdk-6u45-linux-x64.bin /usr/java/jdk-6u45-linux-x64.bin echo "$? copy finish!" cd /usr/java/ sh /usr/java/jdk-6u45-linux-x64.bin echo "$? install jdk finish!" exit 0
set-keygen.sh
#!/bin/bash ssh-keygen -t dsa -P ‘‘ -f ~/.ssh/id_dsa echo "$? set ssh keygen finish!" exit 0
以上是关于shell脚本自动化收集的主要内容,如果未能解决你的问题,请参考以下文章