ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/Processing/bin/download.sh
Revision: 1.6
Committed: Wed Sep 28 21:02:50 2011 UTC (13 years, 7 months ago) by paus
Content type: application/x-sh
Branch: MAIN
CVS Tags: Mit_025
Changes since 1.5: +3 -7 lines
Log Message:
Use of central sample database.

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 paus 1.4 # start next request
11     remainingMax=0
12    
13 paus 1.1 # 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 paus 1.4 dataset="XXX"
29 paus 1.1 startTime=$(date +%s)
30     nowTime=$(date +%s); duration=$(($nowTime - $startTime))
31 paus 1.6 jobs=`condor_q -global $USER -format "%d " ClusterId -format "%s " Cmd -format "%s \n" Args | grep $dataset | grep downloadFiles.sh | wc -l`
32 paus 1.4 while [ $jobs -gt $remainingMax ]
33 paus 1.1 do
34     echo " waiting since $duration sec == condor queue has $jobs jobs left"; sleep 60; echo ""
35 paus 1.5 jobs=`condor_q -global $USER $format | grep $dataset | grep downloadFiles.sh | wc -l`
36 paus 1.4 #jobs=`condor_q -global $USER | grep downloadFiles.sh | wc -l`
37 paus 1.1 nowTime=$(date +%s); duration=$(($nowTime - $startTime))
38     done
39 paus 1.3 echo " Queues are close to empty ($jobs) -- Let's get started."
40 paus 1.1 echo ""
41    
42     # all right, ready to download
43     nSamples=`cat $SAMPLE_LIST | wc -l | cut -d ' ' -f1`
44     i=1
45     while [ $i -le $nSamples ]
46     do
47 paus 1.5 startTime=$(date +%s)
48 paus 1.1
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 paus 1.3 baseDir=`echo $line | tr -s ' ' | cut -d ' ' -f 1`
58 paus 1.1 book=`echo $line | tr -s ' ' | cut -d ' ' -f 2`
59     version=`basename $book`
60     dataset=`echo $line | tr -s ' ' | cut -d ' ' -f 3`
61 paus 1.4 targetDir=`echo $line | tr -s ' ' | cut -d ' ' -f 4`
62 paus 1.1
63 paus 1.3 # stagein the sample if it is at CERN
64     if [ "`echo $baseDir | grep /castor/cern.ch`" != "" ]
65     then
66 paus 1.4 echo " ssh paus@lxplus.cern.ch ./stageSample.py --dataDir=$baseDir/$book/$dataset"
67 paus 1.3 ssh paus@lxplus.cern.ch ./stageSample.py --dataDir=$baseDir/$book/$dataset
68     fi
69    
70     # download the sample
71     echo " downloadSample.sh $line"
72 paus 1.1 downloadSample.sh $line
73    
74 paus 1.3 # go into waiting loop
75 paus 1.1 nowTime=$(date +%s); duration=$(($nowTime - $startTime))
76 paus 1.6 jobs=`condor_q -global $USER -format "%d " ClusterId -format "%s " Cmd -format "%s \n" Args | grep $dataset | grep downloadFiles.sh | wc -l`
77 paus 1.4 while [ $jobs -gt $remainingMax ]
78 paus 1.1 do
79     echo " waiting since $duration sec == condor queue has $jobs jobs left"; sleep 60; echo ""
80 paus 1.6 jobs=`condor_q -global $USER -format "%d " ClusterId -format "%s " Cmd -format "%s \n" Args | grep $dataset | grep downloadFiles.sh | wc -l`
81 paus 1.1 nowTime=$(date +%s); duration=$(($nowTime - $startTime))
82     done
83     echo " Queues are empty ($jobs) --> cleaning up and making catalogs."
84     echo ""
85    
86     # remove zero length files
87 paus 1.4 echo "removeZeroLengthFiles.sh $targetDir/$book/$dataset"
88     removeZeroLengthFiles.sh $targetDir/$book/$dataset
89 paus 1.1
90     # finally make the corresponding catalog
91 paus 1.4 echo "catalog.sh -ceg $version $dataset --retry $targetDir"
92     catalog.sh -ceg $version $dataset --retry $targetDir
93 paus 1.1
94     i=$(( $i+1 ))
95    
96     done
97    
98     exit 0