forked from OleHolmNielsen/Slurm_tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsreboot
executable file
·40 lines (34 loc) · 860 Bytes
/
sreboot
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
38
39
40
#!/usr/bin/env bash
# Slurm: use scontrol to reboot nodes
# NextState is "Resume" by default, use "-d" to set to Down.
# Homepage: https://github.com/OleHolmNielsen/Slurm_tools/
action=resume
reason="reboot and resume"
# Parse command options
while getopts "dh" options; do
case $options in
d ) action=down
reason="reboot and down"
;;
h | * ) echo "Usage:"
echo "$0 [-d] <nodelist>"
echo "The NextState after reboot is Resume. Use -d to set NextState to Down"
exit 1;;
esac
done
shift $((OPTIND-1))
NODES="$1"
if [ $# -ne 1 ]
then
echo "Usage: $0 [-d] nodename-list"
exit 1
fi
# Check the node list
if [ "`sinfo -hN -n $NODES`" = "" ]
then
echo "ERROR: Nodelist $NODES does not exist"
exit 1
fi
echo "Reboot nodes $NODES with nextstate=$action"
scontrol reboot asap nextstate=$action reason="$reason" $NODES
sinfo -N -n $NODES