国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統(tǒng) > Linux > 正文

Shell腳本實現(xiàn)復(fù)制文件到多臺服務(wù)器的代碼分享

2019-10-26 18:42:17
字體:
供稿:網(wǎng)友

在多機集群環(huán)境中,經(jīng)常面臨修改配置文件后拷貝到多臺服務(wù)器的情況,傳統(tǒng)的執(zhí)行scp比較麻煩,所以寫了以下shell腳本,可以將指定文件拷貝到多臺機器。

使用方法請參見HELP部分代碼。

#!/bin/bash help() {  cat << HELP    --------------HELP------------------------    This shell script can copy file to many computers.    Useage:        copytoall filename(full path form /home) targetpathfrom/ username ip1 ip2 ip3....    Example:        copytoall /home/casliyang/Hadoop-2.2.0/etc/hadoop/core-site.xml /home/casliyang/hadoop-2.2.0/etc/hadoop/ casliyang 192.168.0.5 192.168.0.6 192.168.0.7 192.168.0.8    ------------------------------------------ HELP  exit 0 } currentdate=$(date +%Y-%m) echo $currentdate " execute copytoall" if [ $1 = "-h" ] ; then     help    exit 0 fi file=$1 shift targetpath=$1 shift user=$1 shift tempip=0 if [ -f $file ] ; then    while [ $# -gt 0 ] ; do        tempip=$1        shift        scp $file ${user}@${tempip}:${targetpath}    doneelse    echo "wrong file!"    exit 0 fi
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 从江县| 山东| 隆化县| 师宗县| 浠水县| 驻马店市| 大石桥市| 滨海县| 施甸县| 鄂托克旗| 仲巴县| 弋阳县| 大丰市| 沽源县| 景东| 巧家县| 定陶县| 榕江县| 平阳县| 江孜县| 卢龙县| 沅江市| 遂川县| 临泽县| 北辰区| 邳州市| 玉林市| 高雄县| 调兵山市| 阿城市| 潼南县| 凤庆县| 获嘉县| 遂平县| 泾川县| 汽车| 灵宝市| 资阳市| 湘乡市| 长兴县| 颍上县|