| | 113 | |
| | 114 | == Submitting Many Dependent Jobs with Bash Script == |
| | 115 | |
| | 116 | Look at '''SubmitDependentJobs.sh''' |
| | 117 | {{{ |
| | 118 | [fuji@cypress1 JobDependencies]$ cat SubmitDependentJobs.sh |
| | 119 | #!/bin/bash |
| | 120 | EMAIL=$USER@tulane.edu |
| | 121 | WALLTIME_LIMIT=1:00:00 |
| | 122 | export WORKDIR=`pwd` |
| | 123 | # |
| | 124 | QUEUE='--partition=workshop --qos=workshop' |
| | 125 | WALLTIME="--time=$WALLTIME_LIMIT" |
| | 126 | RESORCE="--nodes=1 --ntasks-per-node=1 --cpus-per-task=1" |
| | 127 | OTHERS="--export=ALL --mail-type=END --mail-user=$EMAIL" |
| | 128 | # |
| | 129 | JOB_SETTING="$QUEUE $WALLTIME $RESORCE $OTHERS" |
| | 130 | |
| | 131 | DEPENDENCY="" |
| | 132 | |
| | 133 | while [[ $# > 0 ]] |
| | 134 | do |
| | 135 | JOB=`sbatch --job-name=$DIRNAME$1 $DEPENDENCY $JOB_SETTING ./$1 | awk '{print $4}'`; |
| | 136 | echo $JOB submitted; |
| | 137 | DEPENDENCY="--dependency=afterok:$JOB" ; |
| | 138 | shift |
| | 139 | done |
| | 140 | }}} |
| | 141 | |
| | 142 | This bash script takes script names as command-line options, and submits a sequence of dependent jobs with those scripts. |
| | 143 | |
| | 144 | The bash script, '''script.sh''' is |
| | 145 | {{{ |
| | 146 | [fuji@cypress1 JobDependencies]$ cat script.sh |
| | 147 | #!/bin/bash |
| | 148 | |
| | 149 | module load anaconda |
| | 150 | python addOne.py |
| | 151 | |
| | 152 | sleep 1 |
| | 153 | }}} |
| | 154 | runs '''addOne.py'''. |
| | 155 | |
| | 156 | Let's submit 10 of '''script.sh''', |
| | 157 | {{{ |
| | 158 | [fuji@cypress1 JobDependencies]$ ./SubmitDependentJobs.sh script.sh script.sh script.sh script.sh script.sh script.sh script.sh script.sh script.sh script.sh |
| | 159 | 774001 submitted |
| | 160 | 774002 submitted |
| | 161 | 774003 submitted |
| | 162 | 774004 submitted |
| | 163 | 774005 submitted |
| | 164 | 774006 submitted |
| | 165 | 774007 submitted |
| | 166 | 774008 submitted |
| | 167 | 774009 submitted |
| | 168 | 774010 submitted |
| | 169 | }}} |
| | 170 | |
| | 171 | List jobs, |
| | 172 | {{{ |
| | 173 | [fuji@cypress1 JobDependencies]$ squeue -u fuji |
| | 174 | JOBID QOS NAME USER ST TIME NO NODELIST(REASON) |
| | 175 | 774005 worksh script.sh fuji PD 0:00 1 (Dependency) |
| | 176 | 774006 worksh script.sh fuji PD 0:00 1 (Dependency) |
| | 177 | 774007 worksh script.sh fuji PD 0:00 1 (Dependency) |
| | 178 | 774008 worksh script.sh fuji PD 0:00 1 (Dependency) |
| | 179 | 774009 worksh script.sh fuji PD 0:00 1 (Dependency) |
| | 180 | 774010 worksh script.sh fuji PD 0:00 1 (Dependency) |
| | 181 | 774004 worksh script.sh fuji R 0:01 1 cypress01-117 |
| | 182 | }}} |