ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/Processing/bin/download.sh
Revision: 1.4
Committed: Sat Mar 19 01:49:13 2011 UTC (14 years, 1 month ago) by paus
Content type: application/x-sh
Branch: MAIN
CVS Tags: Mit_024b, Mit_025pre1, Mit_024a, Mit_024, Mit_023, Mit_022a, Mit_022, Mit_020d, TMit_020d, Mit_020c, Mit_021, Mit_021pre2, Mit_021pre1, Mit_020b, Mit_020a, Mit_020
Changes since 1.3: +20 -10 lines
Log Message:
Small updates here and there.

File Contents

# Content
1 #!/bin/bash
2 #---------------------------------------------------------------------------------------------------
3 # Go through a number of download requests
4 #---------------------------------------------------------------------------------------------------
5 H=`basename $0`
6 SAMPLE_LIST=$1
7 MIT_LOCATION="/pnfs/cmsaf.mit.edu/t2bat/cms/store/user/paus"
8 CERN_LOCATION="/castor/cern.ch/user/p/paus"
9
10 # start next request
11 remainingMax=0
12
13 # health checks
14 if [ ".$1" == "." ]
15 then
16 echo "";
17 echo "usage: $H <sampleList>";
18 echo ""
19 exit 1
20 fi
21
22 # say what we do
23 echo ""
24 echo " ==== Download queue from $SAMPLE_LIST ===="
25 echo ""
26
27 # check that queues are really empty
28 dataset="XXX"
29 startTime=$(date +%s)
30 nowTime=$(date +%s); duration=$(($nowTime - $startTime))
31 jobs=`condor_q -global $USER -format "%d " ClusterId -format "%s " Cmd -format "%s \n" Args | grep $dataset | grep downloadFiles.sh | wc -l`
32 #jobs=`condor_q -global $USER | grep downloadFiles.sh | wc -l`
33 while [ $jobs -gt $remainingMax ]
34 do
35 echo " waiting since $duration sec == condor queue has $jobs jobs left"; sleep 60; echo ""
36 jobs=`condor_q -global $USER -format "%d " ClusterId -format "%s " Cmd -format "%s \n" Args | grep $dataset | grep downloadFiles.sh | wc -l`
37 #jobs=`condor_q -global $USER | grep downloadFiles.sh | wc -l`
38 nowTime=$(date +%s); duration=$(($nowTime - $startTime))
39 done
40 echo " Queues are close to empty ($jobs) -- Let's get started."
41 echo ""
42
43 # all right, ready to download
44 nSamples=`cat $SAMPLE_LIST | wc -l | cut -d ' ' -f1`
45 i=1
46 while [ $i -le $nSamples ]
47 do
48
49 line=`head -$i $SAMPLE_LIST | tail -1`
50 if [ "`echo $line | grep ^#`" != "" ]
51 then
52 i=$(( $i+1 ))
53 continue
54 fi
55
56 # define some quantities
57 baseDir=`echo $line | tr -s ' ' | cut -d ' ' -f 1`
58 book=`echo $line | tr -s ' ' | cut -d ' ' -f 2`
59 version=`basename $book`
60 dataset=`echo $line | tr -s ' ' | cut -d ' ' -f 3`
61 targetDir=`echo $line | tr -s ' ' | cut -d ' ' -f 4`
62
63 # stagein the sample if it is at CERN
64 if [ "`echo $baseDir | grep /castor/cern.ch`" != "" ]
65 then
66 echo " ssh paus@lxplus.cern.ch ./stageSample.py --dataDir=$baseDir/$book/$dataset"
67 ssh paus@lxplus.cern.ch ./stageSample.py --dataDir=$baseDir/$book/$dataset
68 fi
69
70 # download the sample
71 echo " downloadSample.sh $line"
72 downloadSample.sh $line
73
74 # go into waiting loop
75 nowTime=$(date +%s); duration=$(($nowTime - $startTime))
76 #jobs=`condor_q -global $USER | grep downloadFiles.sh | wc -l`
77 jobs=`condor_q -global $USER -format "%d " ClusterId -format "%s " Cmd -format "%s \n" Args | grep $dataset | grep downloadFiles.sh | wc -l`
78 while [ $jobs -gt $remainingMax ]
79 do
80 echo " waiting since $duration sec == condor queue has $jobs jobs left"; sleep 60; echo ""
81 #jobs=`condor_q -global $USER | grep downloadFiles.sh | wc -l`
82 jobs=`condor_q -global $USER -format "%d " ClusterId -format "%s " Cmd -format "%s \n" Args | grep $dataset | grep downloadFiles.sh | wc -l`
83 nowTime=$(date +%s); duration=$(($nowTime - $startTime))
84 done
85 echo " Queues are empty ($jobs) --> cleaning up and making catalogs."
86 echo ""
87
88 # remove zero length files
89 echo "removeZeroLengthFiles.sh $targetDir/$book/$dataset"
90 removeZeroLengthFiles.sh $targetDir/$book/$dataset
91
92 # finally make the corresponding catalog
93 echo "catalog.sh -ceg $version $dataset --retry $targetDir"
94 catalog.sh -ceg $version $dataset --retry $targetDir
95
96 i=$(( $i+1 ))
97
98 done
99
100 exit 0