ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitHzz4l/scripts/run_condor.sh
Revision: 1.6
Committed: Tue Oct 23 12:25:17 2012 UTC (12 years, 6 months ago) by dkralph
Content type: application/x-sh
Branch: MAIN
Changes since 1.5: +83 -14 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 dkralph 1.1 #!/bin/bash
2    
3     hostname
4 dkralph 1.6 if hostname | grep 'mit\.edu\|t3btch' &> /dev/null; then
5     . /afs/cern.ch/cms/LCG/LCG-2/UI/cms_ui_env.sh
6     rsync t3btch100.mit.edu:$X509_USER_PROXY $X509_USER_PROXY
7     grid-proxy-info
8     fi
9 dkralph 1.1 ls -ltrh $X509_USER_PROXY
10    
11 dkralph 1.6 command=$@
12 dkralph 1.2 echo "command: $command"
13 dkralph 1.6
14     if hostname | grep 'lx[a-z]\|vmb' &>/dev/null; then
15     . ~/bin/set_cms.sh 029
16     fi
17     cd $CMSSW_BASE/src/MitHzz4l
18    
19     inputfile=`echo $@ | sed 's/[ ][ ]*/\n/g' | grep -A1 '\-\-inputfile' | grep -v "\-\-inputfile"`
20     if echo $inputfile | grep /data/blue/ &>/dev/null && hostname | grep 'lx[a-z]\|vmb' &>/dev/null; then
21     mitMachine=`$HOME/bin/findMitMachine`
22     ssh $mitMachine "/home/$USER/bin/limit_procs rsync" # NOTE: *not* the same file as /afs/cern.ch/user/d/dkralph/bin/limit_procs. Damn kerberos.
23     echo "rsync'ing inputfile: $mitMachine:$inputfile /tmp/dkralph$inputfile"
24     mkdir -p /tmp/dkralph`dirname $inputfile`
25     time rsync $mitMachine:$inputfile /tmp/dkralph$inputfile
26     ls -ltrh /tmp/dkralph`dirname $inputfile`/*
27     command=`echo $command | sed "s@$inputfile@/tmp/dkralph$inputfile@"`
28     fi
29    
30     # for BDT training:
31     if echo $command | grep trainAngles &> /dev/null; then
32     outdir=`echo $command | awk '{print $3}' | xargs dirname`
33     echo "outdir: $outdir"
34     cd $outdir
35     else
36     # write output to /tmp so 1) distributed file systems don't fsck with you and 2) so if the job fails halfway through there isn't a bogus output file lying in the output dir
37     output=`echo $@ | sed 's/[ ][ ]*/\n/g' | grep -A1 '\-\-output' | grep -v "\-\-output"`
38     outdir=`dirname $output`
39     # tmpOutput=`echo $output | sed "s@$outdir/@/tmp/dkralph/@"`
40     tmpOutput=/tmp/dkralph/$output
41     mkdir -p `dirname $tmpOutput`
42     command=`echo $command | sed "s@$output@$tmpOutput@"`
43     echo "command after substitution: $command"
44     if hostname | grep 'lx[a-z]\|vmb' &>/dev/null; then
45     tmpOutLog=`echo $tmpOutput | sed 's/\.root/\.out/'`
46     tmpErrLog=`echo $tmpOutput | sed 's/\.root/\.err/'`
47     fi
48     fi
49    
50     if hostname | grep 'lx[a-z]\|vmb' &>/dev/null && ! echo $command | grep trainAngles &> /dev/null; then
51     echo "redirecting command to $tmpOutLog, $tmpErrLog"
52     $command 1>$tmpOutLog 2>$tmpErrLog
53     else
54     $command
55     fi
56    
57     outLog=`echo $output | sed 's@/dkralph/@/dkralph/logs/@' | sed 's/\.root/\.out/'`
58     errLog=`echo $output | sed 's@/dkralph/@/dkralph/logs/@' | sed 's/\.root/\.err/'`
59     echo "rsync $tmpOutLog $outLog"
60     echo "rsync $tmpErrLog $errLog"
61     rsync $tmpOutLog $outLog
62     rsync $tmpErrLog $errLog
63     rm -fv $tmpOutLog $tmpErrLog
64    
65     if [ "$?" == "0" ]; then
66     echo "exe succeeded..."
67     else
68     echo "exe failed: $?"
69     exit 1
70     fi
71    
72     if echo $command | grep trainAngles &> /dev/null; then
73     exit 0
74     fi
75 dkralph 1.1
76 dkralph 1.4 # rsync the file to the actual output dir
77     echo "hostname: " `hostname`
78     if hostname | grep 'mit\.edu\|t3btch' &> /dev/null; then
79 dkralph 1.6 if echo $outdir | grep '/temp' &> /dev/null; then
80     outputHost=t3btch100.mit.edu:
81     elif echo $outdir | grep '/scratch' &> /dev/null; then
82     outputHost=t3serv004.mit.edu:
83     fi
84 dkralph 1.3 else
85     outputHost=
86     fi
87 dkralph 1.6 filesToCopy="$tmpOutput `echo $tmpOutput | sed 's/\.root/\.nevents/'`"
88     #echo "rsync'ing: rsync -v /tmp/dkralph/`basename $output | sed 's/.root/.\*/'` $outputHost$outdir"
89     #rsync -v /tmp/dkralph/`basename $output | sed 's/.root/.\*/'` $outputHost$outdir
90     echo "rsync'ing: $filesToCopy $outputHost$outdir"
91     rsync $filesToCopy $outputHost$outdir
92 dkralph 1.2
93 dkralph 1.6 ls -ltrh `dirname $tmpOutput`/*
94     rm -fv $filesToCopy
95     if echo $inputfile | grep /data/blue/ &>/dev/null && hostname | grep 'lx[a-z]\|vmb' &>/dev/null; then
96     rm -vf /tmp/dkralph$inputfile
97     fi