ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitHzz4l/scripts/run_condor.sh
Revision: 1.7
Committed: Mon Dec 17 17:23:53 2012 UTC (12 years, 5 months ago) by dkralph
Content type: application/x-sh
Branch: MAIN
CVS Tags: compiled, HEAD
Changes since 1.6: +2 -1 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 dkralph 1.7 status=$?
57 dkralph 1.6
58     outLog=`echo $output | sed 's@/dkralph/@/dkralph/logs/@' | sed 's/\.root/\.out/'`
59     errLog=`echo $output | sed 's@/dkralph/@/dkralph/logs/@' | sed 's/\.root/\.err/'`
60     echo "rsync $tmpOutLog $outLog"
61     echo "rsync $tmpErrLog $errLog"
62     rsync $tmpOutLog $outLog
63     rsync $tmpErrLog $errLog
64     rm -fv $tmpOutLog $tmpErrLog
65    
66 dkralph 1.7 if [ "$status" == "0" ]; then
67 dkralph 1.6 echo "exe succeeded..."
68     else
69     echo "exe failed: $?"
70     exit 1
71     fi
72    
73     if echo $command | grep trainAngles &> /dev/null; then
74     exit 0
75     fi
76 dkralph 1.1
77 dkralph 1.4 # rsync the file to the actual output dir
78     echo "hostname: " `hostname`
79     if hostname | grep 'mit\.edu\|t3btch' &> /dev/null; then
80 dkralph 1.6 if echo $outdir | grep '/temp' &> /dev/null; then
81     outputHost=t3btch100.mit.edu:
82     elif echo $outdir | grep '/scratch' &> /dev/null; then
83     outputHost=t3serv004.mit.edu:
84     fi
85 dkralph 1.3 else
86     outputHost=
87     fi
88 dkralph 1.6 filesToCopy="$tmpOutput `echo $tmpOutput | sed 's/\.root/\.nevents/'`"
89     #echo "rsync'ing: rsync -v /tmp/dkralph/`basename $output | sed 's/.root/.\*/'` $outputHost$outdir"
90     #rsync -v /tmp/dkralph/`basename $output | sed 's/.root/.\*/'` $outputHost$outdir
91     echo "rsync'ing: $filesToCopy $outputHost$outdir"
92     rsync $filesToCopy $outputHost$outdir
93 dkralph 1.2
94 dkralph 1.6 ls -ltrh `dirname $tmpOutput`/*
95     rm -fv $filesToCopy
96     if echo $inputfile | grep /data/blue/ &>/dev/null && hostname | grep 'lx[a-z]\|vmb' &>/dev/null; then
97     rm -vf /tmp/dkralph$inputfile
98     fi