• linux批量远程多服务器FTP并下载文件的脚本


    #!/bin/bash
    time=`date +%Y%m`
    day=`date -d '-1 days' +%Y%m%d`
    localDir="/DBBackup/GameDB"
    cd $localDir
    #ip_game.ini配置ftp服务器的ip,账号,密码等,格式自己定义

    #比如:Server1  username userpasswd  1.1.1.1  Dbbackup


    servername=(`cat /DBBackup/ip_game.ini | awk -F " " '{print $1}'`)
    user=(`cat /DBBackup/ip_game.ini | awk -F " " '{print $2}'`)
    passwd=(`cat /DBBackup/ip_game.ini | awk -F " " '{print $3}'`)
    ip=(`cat /DBBackup/ip_game.ini | awk -F " " '{print $4}'`)
    dbname=(`cat /DBBackup/ip_game.ini | awk -F " " '{print $5}'`)

    if [[ -z $time ]]
    then
      cd $time && mkdir $day
    else
      mkdir $time
      cd $time && mkdir $day
    fi

    len=${#ip[*]}
    num=0
    while [ $num -lt $len ]
    do
      echo "=======${user[$num]}==========="
      echo "=======${passwd[$num]}========="
      echo "=======${ip[$num]}========="
    cd $localDir/$time/$day

    if [[ -z ${servername[$num]} ]]
    then
        cd ${servername[$num]}
    else
        mkdir ${servername[$num]}
    fi

    lftp ftp://${user[$num]}:"${passwd[$num]}"@${ip[$num]} <<END
    lcd $localDir/$time/$day/${servername[$num]}
    cd ${dbname[$num]}
    echo ${dbname[$num]}
    #mget  empiregame_*_$(date  +%Y%m%d).rar
    mget  empiregame_*_$(date -d '-1 days' +%Y%m%d)*.tar.gz
    mget  empireaccount_$(date -d '-1 days' +%Y%m%d)*.tar.gz
    mget  empirecards_$(date -d '-1 days' +%Y%m%d)*.tar.gz
    mget  empiregame_*_$(date -d '-1 days' +%Y%m%d)*.rar
    bye
    END

     let num++
    done

  • 相关阅读:
    Java Web学习笔记3
    Java学习笔记11
    diff 比较两个文件的差异
    Java学习笔记10
    appium——如何导出夜神模拟器下载“微信”app的apk
    python之文件操作模块(os和shutil)
    浅谈HTTP和HTTPS
    LUNIX命令集
    ubuntu软件管理工具的使用——dpkg和apt
    CSS学习—day1
  • 原文地址:https://www.cnblogs.com/franjia/p/4384109.html
Copyright © 2020-2023  润新知