forked from cdt-data-science/cluster-scripts
-
Notifications
You must be signed in to change notification settings - Fork 1
/
onallnodes
executable file
·38 lines (30 loc) · 996 Bytes
/
onallnodes
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
31
32
33
34
35
36
37
#!/bin/bash
nodes=`sinfo --format="%N" --noheader`
print_usage () {
cat << EOM
Usage: $0 [-n nodelist] script
Runs given script on all nodes by submitting supplied script with sbatch.
Arguments:
script the script to be submitted to slurm via sbatch
-n (optional) specify nodes, either comma separated list, or summarised.
Mirrors slurm command -n usage in sinfo, and -w usage for squeue."
EOM
}
while getopts 'n:' flag; do
case "${flag}" in
n) nodes="${OPTARG}" ;;
*) print_usage
exit 1 ;;
esac
done
shift $((OPTIND-1))
script="${@}"
if [ "$script" = "" ]; then
>&2 echo "You must supply a script"
exit 1
fi
node_partition_list=`sinfo --format="%n,%R" --noheader -n ${nodes} -N`
node=`echo "${node_partition_list}" | cut -f1 -d','`
partition=`echo "${node_partition_list}" | cut -f2 -d','`
echo "running $script on nodes $nodes"
parallel --link "sbatch --partition={1} --nodelist={2} ${script}" ::: $partition ::: $node