Automated download and detection of FTP file backup shell script _linux Shell

Source: Internet
Author: User
Tags ftp file mkdir

Implementation code:

#!/bin/bash #ftime0 =$ (ll/root/hbshell/down.txt | awk ' {print $} ') #ftime1 =$ (ll/root/hbshell/down.txt | awk ' {print $} 
') 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/d Own.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 &L
t;<!
 
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)) doing if [[F $ (Echo ${gg[$j]}]] then ls-l $ (ech o ${gg[$j]}) num= $num +1 Else echo-e "\033[31m File ${gg[$j]} not down!! \033[0m "fi done Echo", "That's Files all down, Total is $num" \cp/root/hbshell/down.txt/root/hbshell/down_cp.txt fi D One

The above is the Linux Automation download and detect FTP file backup implementation code, need friends can refer to, if there are server permissions, personal recommendations to use rsync

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.