11#! /usr/bin/env bash
22set -euo pipefail
33offset=0
4+ dry=false
45usage () {
56 echo " " "
67 Run jobs from a slurm submission script's job list on
78 the current interactive node; be nice and keep NUM_JOBS
89 low, since this is only meant for rapid testing
910
10- USAGE: $0 [JOB_LIST] [LOG_DIR] [NUM_JOBS] [OFFSET]
11+ USAGE: $0 [JOB_LIST] [LOG_DIR] [NUM_JOBS] [OFFSET] [DRY]
1112 JOB_LIST file with job scripts, one per line
1213 LOG_DIR directory for log files (clobbered)
1314 NUM_JOBS the number of parallel jobs to run
1415 OFFSET offset of the first job; NUM_JOBS
1516 consecutive lines will be used
1617 default: $offset
18+ DRY set to '1' for a dry-run (no submission)
19+ default: run immediately
1720 " " "
1821}
1922
@@ -25,6 +28,7 @@ job_list=$1
2528log_dir=$2
2629num_jobs=$3
2730[ $# -ge 4 ] && offset=$4
31+ [ $# -ge 5 ] && dry=true
2832
2933if [ ! -f " $job_list " ]; then
3034 echo " ERROR: File '$job_list ' not found"
4246echo " SUBMITTING:"
4347tail -n +$(( offset + 1 )) $job_list | head -n $num_jobs | while IFS= read -r cmd; do
4448 echo " JOB $i : $cmd "
45- # $cmd > $log_dir/job.$i.out 2> $log_dir/job.$i.err &
49+ if ! $dry ; then
50+ $cmd > $log_dir /job.$i .out 2> $log_dir /job.$i .err &
51+ fi
4652 i=$(( i+ 1 ))
4753done
48- echo " " "
54+ if $dry ; then
55+ echo " THIS WAS A DRY-RUN; no jobs submitted"
56+ else
57+ echo " " "
4958JOBS SUBMITTED.
5059- They are running in the backround
5160- Monitor with \` htop -u $( whoami) \`
5261- Logs written to \` $log_dir \`
53- " " "
62+ " " "
63+ fi
0 commit comments