ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/FGolf/BatchSubmitCMS2/resubmitConfig.sh
Revision: 1.2
Committed: Tue May 28 07:01:35 2013 UTC (11 years, 11 months ago) by fgolf
Content type: application/x-sh
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +13 -7 lines
Log Message:
new version

File Contents

# User Rev Content
1 kelley 1.1 #/bin/bash
2    
3     # ------------------------------------------------------------------------------- #
4     # resubmitConfig.sh -- creates a config file to resubmit jobs that failed #
5     # #
6     # description: This script will search the output dir for the given condor script #
7     # and determine which files do not exist. It uses this list of #
8     # missing files to create a new sumission script. This script #
9     # is the same name as the original script except with an _resubmit #
10     # appended to the name #
11     # #
12     # usage: ./resubmitConfig.sh <condor_script_file> #
13     # #
14     # <condor_script_file> is the originially submitted condor script #
15     # #
16     # #
17     # ------------------------------------------------------------------------------- #
18    
19     # input
20     # ------------------------------------------------------------------------------- #
21    
22     condor_script_filename=$1
23    
24     if [ ! -f "$condor_script_filename" ]; then
25     echo "File $condor_script_filename not found. Exiting"
26     exit 1
27     fi
28    
29     # get the arguments lines from the original submission
30     # ------------------------------------------------------------------------------- #
31    
32     # get the list of args into an array
33     index=0
34     while read line ; do
35 fgolf 1.2 if [ -n "$(echo $line | grep argument)" ]; then
36     #arg_list[$index]=$(echo $line | sed s/\"\"/\\\\\"\\\\\"/g) # don't need this anymore?
37     arg_list[$index]=$(echo $line)
38     index=$(($index+1))
39     fi
40     done < "${condor_script_filename}"
41 kelley 1.1 num_args=${#arg_list[@]}
42    
43     # get output path
44 fgolf 1.2 output_path=$(echo ${arg_list[0]} | awk '{print $7}' | sed s/\"//g)
45 kelley 1.1
46     # output files to find -- if found, the index is stored
47     for (( i=0; i < $num_args; i++ ));
48     do
49 fgolf 1.2 input_file=$(echo ${arg_list[$i]} | awk '{print $2}')
50 kelley 1.1 file=$(basename ${input_file})
51 fgolf 1.2 #echo find $output_path -type f -name $file
52 kelley 1.1 if [ ! $(find $output_path -type f -name $file) ]; then
53     index_of_missing_files=(${index_of_missing_files[@]} $i)
54     fi
55     done
56    
57     # form the resubmissing script
58     # ------------------------------------------------------------------------------- #
59    
60     # if there are missing files, create the resubmit script
61     num_missing_files=${#index_of_missing_files[@]}
62     if [ ${num_missing_files} -gt 0 ]; then
63    
64     # same name as originial condor script with _resubmit appended
65     condor_resubmit_script_filename=${condor_script_filename%.*}_resubmit.cmd
66     echo Missing ${num_missing_files} / ${num_args} files
67     echo creating resumit list: $condor_resubmit_script_filename
68    
69     # do the same header as original file
70     head -n 15 $condor_script_filename > $condor_resubmit_script_filename
71    
72     for (( i=0; i < ${num_missing_files}; i++ ));
73     do
74     cat >> $condor_resubmit_script_filename << EOF
75    
76     executable=wrapper.sh
77     transfer_executable=True
78     ${arg_list[${index_of_missing_files[$i]}]}
79     queue
80    
81     EOF
82     done
83     else
84     echo "No missing files"
85 fgolf 1.2
86     # create a blank resubmit script
87     condor_resubmit_script_filename=${condor_script_filename%.*}_resubmit.cmd
88     head -n 15 $condor_script_filename > $condor_resubmit_script_filename
89 kelley 1.1 fi