1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
#!/bin/bash
function
DownLoad()
{
local
url=$1
local
dirpath=$2
wget --
ftp
-user=gsics --
ftp
-password=gsics \
-c -r -q -e robots=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=`
ps
aux |
grep
${psname}|
wc
-l`
if
[ $psNum -gt 3 ]
then
cdir=`
pwd
`
echo
'Process is Running .'
>${cdir}
/tmp
.log
echo
`
date
` >>${cdir}
/tmp
.log
exit
fi
DATADIR=
/nas03/v6/AQUA/MODIS/L1/ORBIT
thread=5
if
[ $
# -eq 2 ];then
stime=$1
etime=$2
else
stime=`
date
--
date
=
"-16 day"
+%Y%m%d`
etime=`
date
--
date
=
"-1 day"
+%Y%m%d`
fi
let
Flag=0
while
:
do
if
[ ${Flag} -
eq
1 ];
then
stime=$(
date
-d
"$stime 1day"
+%Y%m%d)
fi
let
Flag=1
stime=$(
date
-d
"$stime 1day"
+%Y%m%d)
if
[[ $stime -gt $etime ]];
then
break
fi
cat
> ftpawx33.tmp << EOF
user gsics gsics
as
cd
/AQUA/MODIS/L1/ORBIT/
${stime:0:6}
nlist
quit
EOF
echo
${stime}
jjj=`
date
-d
"${stime}"
+%j`
ftp
-
v
-n -i 10.0.66.33 < ftpawx33.tmp > ftpnamelist33.info
cat
ftpnamelist33.info |
grep
"^MYD"
|
grep
".A${stime:0:4}${jjj}"
|
grep
".006."
>namelist33.txt
if
[[ ! -s namelist33.txt ]]
then
continue
;
fi
if
[ ! -d $DATADIR/${stime:0:6} ]
then
mkdir
-p $DATADIR/${stime:0:6}
fi
DirPath=$DATADIR/${stime:0:6}/
declare
-a order_array
let
jj=0
for
Name
in
`
cat
namelist33.txt`
do
url=
ftp
:
//10
.0.66.33:
/AQUA/MODIS/L1/ORBIT/
${stime:0:6}/$Name
order_array[$jj]=${url}
let
jj=${jj}+1
done
if
[ ${
#order_array[@]} -eq 0 ];then
unset
${order_array}
continue
fi
tmp_fifofile=
"/tmp/$$.fifo"
mkfifo
$tmp_fifofile
exec
6<> $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
exec
6>&-
unset
${order_array}
done
|
本文转自 SoulMio 51CTO博客,原文链接:http://blog.51cto.com/bovin/1937467,如需转载请自行联系原作者