自動(dòng)化下載并檢測(cè)ftp文件備份的shell腳本
實(shí)現(xiàn)代碼:
#!/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 :
do
if [[ /root/hbshell/down.txt -nt /root/hbshell/down_cp.txt ]]
then
user=root
passwd=19871022
host=192.168.1.202
dir=/tmp/down/$(date +%Y%m%d)/$(date +%H%M)
mkdir -p $dir
cd $dir
#cat /root/hbshell/down.txt|sed -e 's#^ */##' -e 's# *##' -e 's#^[^a-zA-Z]*##'>/root/hbshell/zdown.txt
cat /root/hbshell/down.txt|sed 's#^[^a-zA-Z]*##'>/root/hbshell/zdown.txt
declare -a gg=($(cat /root/hbshell/zdown.txt))
declare -i i
for ((i=0;i<${#gg[@]};i=$i+1))
do
echo ${gg[$i]}|grep -q "/"
if echo $?| grep -q 0
then
tmpdir=$(echo ${gg[$i]} | sed 's#\(.*/\)\(.*$\)#\1#')
mkdir -p ./$tmpdir
fi
done
/usr/bin/ftp -i -in <<!
open $host
user $user $passwd
bin
mget $(echo ${gg[@]})
bye
!
declare -i j
declare -i num
num=0
for ((j=0;j<${#gg[@]};j=$j+1))
do
if [[ -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
done
echo "That Files all down total is $num "
\cp /root/hbshell/down.txt /root/hbshell/down_cp.txt
fi
done
以上就是linux下自動(dòng)化下載并檢測(cè)ftp文件備份的實(shí)現(xiàn)代碼,需要的朋友可以參考一下,如果有服務(wù)器權(quán)限,個(gè)人建議使用rsync
- PowerShell 自動(dòng)備份oracle并上傳到ftp
- CentOS中使用Shell腳本實(shí)現(xiàn)每天自動(dòng)備份網(wǎng)站文件和數(shù)據(jù)庫(kù)并上傳到FTP中
- Shell腳本自動(dòng)備份MySQL到FTP并定期清理過(guò)期備份
- Linux下使用Shell腳本實(shí)現(xiàn)ftp的自動(dòng)上傳下載的代碼小結(jié)
- linux和windows下的自動(dòng)ftp腳本(shell bat)
- linux下實(shí)現(xiàn)ftp自動(dòng)備份shell腳本
- linux下自動(dòng)備份MySQL數(shù)據(jù)并上傳到FTP上的shell腳本
- Shell腳本實(shí)現(xiàn)FTP自動(dòng)上傳和下載文件
相關(guān)文章
linux上搭建solr的實(shí)現(xiàn)方法(用jetty部署)
下面小編就為大家分享一篇linux上搭建solr的實(shí)現(xiàn)方法(用jetty部署),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2017-12-12
shell腳本監(jiān)控linux系統(tǒng)內(nèi)存使用情況的方法(不使用nagios監(jiān)控linux)
在沒(méi)有nagios監(jiān)控軟件的情況下,只要服務(wù)器能上互聯(lián)網(wǎng),就可通過(guò)發(fā)郵件的方式來(lái)提醒管理員系統(tǒng)內(nèi)存的使用情況2014-02-02
Linux Shell 自動(dòng)交互功能實(shí)現(xiàn)
本文主要介紹了Linux Shell 自動(dòng)交互功能實(shí)現(xiàn),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2022-08-08
非常實(shí)用的23個(gè)Shell腳本實(shí)例
為大家整理了23個(gè)實(shí)例,通過(guò)23個(gè)實(shí)戰(zhàn)經(jīng)典腳本實(shí)例,可以拿來(lái)就用,根據(jù)大家的需求可以直接使用,為大家整理了23個(gè)實(shí)例,希望此文章對(duì)各位有所幫助2021-06-06
Shell?腳本自動(dòng)輸入密碼的三種方式小結(jié)
本文主要介紹了Shell?腳本自動(dòng)輸入密碼的三種方式小結(jié),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2022-07-07
shell腳本實(shí)現(xiàn)定時(shí)刪除文件或文件夾
本文主要介紹了shell腳本實(shí)現(xiàn)定時(shí)刪除文件或文件夾,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2022-08-08

