ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/Processing/bin/download.sh
Revision: 1.3
Committed: Thu Jan 6 22:30:07 2011 UTC (14 years, 4 months ago) by paus
Content type: application/x-sh
Branch: MAIN
CVS Tags: Mit_020pre1, Mit_018
Changes since 1.2: +18 -11 lines
Log Message:
Adding more powerful copy.

File Contents

# User Rev Content
1 paus 1.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     # health checks
11     if [ ".$1" == "." ]
12     then
13     echo "";
14     echo "usage: $H <sampleList>";
15     echo ""
16     exit 1
17     fi
18    
19     # say what we do
20     echo ""
21     echo " ==== Download queue from $SAMPLE_LIST ===="
22     echo ""
23    
24     # check that queues are really empty
25     startTime=$(date +%s)
26     nowTime=$(date +%s); duration=$(($nowTime - $startTime))
27 paus 1.3 jobs=`condor_q -global $USER | grep downloadFiles.sh | wc -l`
28     while [ $jobs -gt 15 ]
29 paus 1.1 do
30     echo " waiting since $duration sec == condor queue has $jobs jobs left"; sleep 60; echo ""
31 paus 1.3 jobs=`condor_q -global $USER | grep downloadFiles.sh | wc -l`
32 paus 1.1 nowTime=$(date +%s); duration=$(($nowTime - $startTime))
33     done
34 paus 1.3 echo " Queues are close to empty ($jobs) -- Let's get started."
35 paus 1.1 echo ""
36    
37     # all right, ready to download
38     nSamples=`cat $SAMPLE_LIST | wc -l | cut -d ' ' -f1`
39     i=1
40     while [ $i -le $nSamples ]
41     do
42    
43     line=`head -$i $SAMPLE_LIST | tail -1`
44     if [ "`echo $line | grep ^#`" != "" ]
45     then
46     i=$(( $i+1 ))
47     continue
48     fi
49    
50     # define some quantities
51 paus 1.3 baseDir=`echo $line | tr -s ' ' | cut -d ' ' -f 1`
52 paus 1.1 book=`echo $line | tr -s ' ' | cut -d ' ' -f 2`
53     version=`basename $book`
54     dataset=`echo $line | tr -s ' ' | cut -d ' ' -f 3`
55    
56 paus 1.3 # stagein the sample if it is at CERN
57     if [ "`echo $baseDir | grep /castor/cern.ch`" != "" ]
58     then
59     ssh paus@lxplus.cern.ch ./stageSample.py --dataDir=$baseDir/$book/$dataset
60     fi
61    
62     # download the sample
63     echo " downloadSample.sh $line"
64 paus 1.1 downloadSample.sh $line
65    
66 paus 1.3 # go into waiting loop
67 paus 1.1 nowTime=$(date +%s); duration=$(($nowTime - $startTime))
68 paus 1.3 jobs=`condor_q -global $USER | grep downloadFiles.sh | wc -l`
69     while [ $jobs -gt 15 ]
70 paus 1.1 do
71     echo " waiting since $duration sec == condor queue has $jobs jobs left"; sleep 60; echo ""
72 paus 1.3 jobs=`condor_q -global $USER | grep downloadFiles.sh | wc -l`
73 paus 1.1 nowTime=$(date +%s); duration=$(($nowTime - $startTime))
74     done
75     echo " Queues are empty ($jobs) --> cleaning up and making catalogs."
76     echo ""
77    
78     # remove zero length files
79     echo "removeZeroLengthFiles.sh /mnt/hadoop/cmsprod/$book/$dataset"
80     removeZeroLengthFiles.sh /mnt/hadoop/cmsprod/$book/$dataset
81    
82     # finally make the corresponding catalog
83 paus 1.3 echo "catalog.sh -ceg $version $dataset --retry /mnt/hadoop/cmsprod"
84 paus 1.1 catalog.sh -ceg $version $dataset --retry /mnt/hadoop/cmsprod
85    
86     i=$(( $i+1 ))
87    
88     done
89    
90     exit 0