-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrichamp_scale_and_subset.sh
executable file
·30 lines (30 loc) · 1.41 KB
/
richamp_scale_and_subset.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/bash
logfile=${0}.log
targetScript="richamp_scale_and_subset.scr"
jobCheckIntervalSeconds=15
for ending in submit start finish error ; do
rm -f $targetScript.$ending # remove .submit .start .finish and .error if they are left over
done
#
echo "[$(date +'%Y-%h-%d-T%H:%M:%S%z')] $0: Submitting $targetScript $logfile" > $targetScript.submit | tee --append $logfile
sbatch richamp-support/$targetScript $logfile 2>>jobErr >jobID
# check to see if the sbatch command succeeded; you can also add a retry
# but maybe not necessary
if [[ $? == 0 ]]; then
echo "[$(date +'%Y-%h-%d-T%H:%M:%S%z')] $0: Job ID for $targetScript is $(<jobID)" >> $logfile
else
echo "[$(date +'%Y-%h-%d-T%H:%M:%S%z')] $0: The sbatch command failed for $targetScript." >> $logfile
exit
fi
# wait for batch job to start
until [[ -e $targetScript.start ]]; do
echo "[$(date +'%Y-%h-%d-T%H:%M:%S%z')] Waiting for $targetScript to start." >> $logfile
sleep $jobCheckIntervalSeconds
done
echo "[$(date +'%Y-%h-%d-T%H:%M:%S%z')] The batch job for $targetScript has started." >> $logfile
# wait for batch job to finish successfully or exit with an error
until [[ -e $targetScript.finish || -e $targetScript.error ]]; do
echo "[$(date +'%Y-%h-%d-T%H:%M:%S%z')] Waiting for $targetScript to finish." >> $logfile
sleep $jobCheckIntervalSeconds
done
echo "[$(date +'%Y-%h-%d-T%H:%M:%S%z')] The batch job for $targetScript has exited." >> $logfile