Skip to content

Instantly share code, notes, and snippets.

@cmd-ntrf
Created February 2, 2020 10:38
Show Gist options
  • Save cmd-ntrf/f356cf761d3b20a926e2899e0aa46a73 to your computer and use it in GitHub Desktop.
Save cmd-ntrf/f356cf761d3b20a926e2899e0aa46a73 to your computer and use it in GitHub Desktop.
Suspend/resume draft
#!/bin/bash
echo "`date` $2 $1" >> /etc/slurm/elastic.log
# Parsing slurm array format (ex. `node[1-4]`, `node[1,3-5]`, `node2`)
node=$(echo "$1" | grep -Po '[a-zA-Z]+')
gcloud auth activate-service-account --key-file=/etc/slurm/credentials.json
for i in $(echo "$1" | grep -Po '\d+[-\d+]*')
do
range=$(echo "$i" | grep -Po '\d+')
if [[ `echo $range | wc -w` -eq 1 ]]
then
range="$range $range"
fi
for j in $(seq $range)
do
gcloud compute instances $2 "$node$j" --async --zone=${zone} --quiet >> \
/etc/slurm/elastic.log
done
done
#!/bin/bash
/etc/slurm/elastic.sh $1 start
# Add the following to slurm.conf
# Elastic Computing
SuspendProgram=/etc/slurm/suspend.sh
ResumeProgram=/etc/slurm/resume.sh
SuspendTime=90
SuspendExcNodes=node[1-127]
#!/bin/bash
/etc/slurm/elastic.sh $1 stop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment