首页 > 代码库 > shell脚本自动化收集
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 root@$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 root@$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脚本自动化收集
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。