shell多线程实现从ftp下载数据
发布时间:2020-12-15 16:53:27 所属栏目:安全 来源:网络整理
导读:#!/bin/bashfunctionDownLoad(){localurl=$1localdirpath=$2wget--ftp-user=gsics--ftp-password=gsics-c-r-q-erobots=off--reject="index.html*"--tries=5--timeout=20--waitretry=10--wait=3--no-parent-nd-nH--dont-remove-listing--directory-pr
#!/bin/bash functionDownLoad() { localurl=$1 localdirpath=$2 wget--ftp-user=gsics--ftp-password=gsics -c-r-q-erobots=off--reject="index.html*" --tries=5 --timeout=20 --waitretry=10 --wait=3 --no-parent -nd-nH--dont-remove-listing --directory-prefix=${dirpath} ${url} } psname=$0 psNum=`psaux|grep${psname}|wc-l` if[$psNum-gt3] then cdir=`pwd` echo'ProcessisRunning.'>${cdir}/tmp.log echo`date`>>${cdir}/tmp.log exit fi DATADIR=/nas03/v6/AQUA/MODIS/L1/ORBIT thread=5 if[$#-eq2];then stime=$1 etime=$2 else stime=`date--date="-16day"+%Y%m%d` etime=`date--date="-1day"+%Y%m%d` fi letFlag=0 while: do if[${Flag}-eq1];then stime=$(date-d"$stime1day"+%Y%m%d) fi letFlag=1 stime=$(date-d"$stime1day"+%Y%m%d) if[[$stime-gt$etime]];then break fi cat>ftpawx33.tmp<<EOF usergsicsgsics as cd/AQUA/MODIS/L1/ORBIT/${stime:0:6} nlist quit EOF echo${stime} jjj=`date-d"${stime}"+%j` ftp-v-n-i10.0.66.33<ftpawx33.tmp>ftpnamelist33.info catftpnamelist33.info|grep"^MYD"|grep".A${stime:0:4}${jjj}"|grep".006.">namelist33.txt if[[!-snamelist33.txt]] then continue; fi if[!-d$DATADIR/${stime:0:6}] then mkdir-p$DATADIR/${stime:0:6} fi DirPath=$DATADIR/${stime:0:6}/ declare-aorder_array letjj=0 forNamein`catnamelist33.txt` do url=ftp://10.0.66.33:/AQUA/MODIS/L1/ORBIT/${stime:0:6}/$Name order_array[$jj]=${url} letjj=${jj}+1 done if[${#order_array[@]}-eq0];then unset${order_array} continue fi tmp_fifofile="/tmp/$$.fifo" mkfifo$tmp_fifofile exec6<>$tmp_fifofile rm$tmp_fifofile for((i=0;i<$thread;i++)); do echo done>&6 for((i=0;i<${#order_array[@]};i++)); do read-u6 { DownLoad${order_array[$i]}${DirPath} echo>&6 }& done wait exec6>&- unset${order_array} done (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |