shell多线程实现从ftp下载数据

前端之家收集整理的这篇文章主要介绍了shell多线程实现从ftp下载数据前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
#!/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
原文链接:https://www.f2er.com/bash/392671.html

猜你在找的Bash相关文章