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

首頁 > 開發 > Linux Shell > 正文

自動化下載并檢測ftp文件備份的shell腳本

2020-07-27 19:01:28
字體:
來源:轉載
供稿:網友

實現代碼:

#!/bin/bash#ftime0=$(ll /root/hbshell/down.txt | awk '{print $7}')#ftime1=$(ll /root/hbshell/down.txt | awk '{print $7}')touch /root/hbshell/down.txt while :doif [[ /root/hbshell/down.txt -nt /root/hbshell/down_cp.txt ]]then user=rootpasswd=19871022host=192.168.1.202dir=/tmp/down/$(date +%Y%m%d)/$(date +%H%M)mkdir -p $dircd $dir#cat /root/hbshell/down.txt|sed -e 's#^ */##' -e 's# *##' -e 's#^[^a-zA-Z]*##'>/root/hbshell/zdown.txtcat /root/hbshell/down.txt|sed 's#^[^a-zA-Z]*##'>/root/hbshell/zdown.txt declare -a gg=($(cat /root/hbshell/zdown.txt))declare -i ifor ((i=0;i<${#gg[@]};i=$i+1))doecho ${gg[$i]}|grep -q "/"if echo $?| grep -q 0then tmpdir=$(echo ${gg[$i]} | sed 's#/(.*//)/(.*$/)#/1#')mkdir -p ./$tmpdir fidone/usr/bin/ftp -i -in <<!open $host user $user $passwdbinmget $(echo ${gg[@]}) bye! declare -i jdeclare -i numnum=0for ((j=0;j<${#gg[@]};j=$j+1))doif [[ -f $(echo ${gg[$j]}) ]]	 then		 ls -l $(echo ${gg[$j]})		num=$num+1		 else		echo -e "/033[31m File ${gg[$j]} is not down!! /033[0m"	  fi doneecho "That Files all down total is $num "/cp /root/hbshell/down.txt /root/hbshell/down_cp.txtfidone

以上就是linux下自動化下載并檢測ftp文件備份的實現代碼,需要的朋友可以參考一下,如果有服務器權限,個人建議使用rsync

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 喀喇| 府谷县| 扶沟县| 铜梁县| 台中市| 抚远县| 康保县| 阿鲁科尔沁旗| 商丘市| 延寿县| 清河县| 衡东县| 迭部县| 镇远县| 武汉市| 吴江市| 石家庄市| 邢台县| 齐河县| 庆阳市| 威远县| 鸡东县| 保山市| 镶黄旗| 静宁县| 延庆县| 靖安县| 夏邑县| 卫辉市| 岑溪市| 洛隆县| 台北县| 红安县| 博乐市| 台北市| 萝北县| 瑞昌市| 阳东县| 临沧市| 榆林市| 南木林县|