From abad7d298f35b092a6e8e486acf4af4e76c25945 Mon Sep 17 00:00:00 2001 From: Thomas de Roo Date: Tue, 21 Nov 2023 15:13:48 +0100 Subject: [PATCH] Update rebootSchedule.sh --- rebootSchedule.sh | 151 +++++++++++++++++++++------------------------- 1 file changed, 70 insertions(+), 81 deletions(-) diff --git a/rebootSchedule.sh b/rebootSchedule.sh index 38ff3af..0737af4 100644 --- a/rebootSchedule.sh +++ b/rebootSchedule.sh @@ -1,81 +1,70 @@ -#!/bin/bash - -# Zie ook https://wiki.de-roo.org/doku.php/cron - -FIRST=("fs01") -SECOND=("web06" "web03" "net04") -THIRD=("net02" "net03" "net05" ) -REST=("dt03" "git01" "run01" "has01" "iam01" "man01" "mdm01" "minecraft" "nms01" "pbx01" "rpi03" "web04" "web05" "web07" "mail02" "cloud01" "srv01" "siem01" "web08" "web09" "dms01") - -############################################ -# 1:00h (uit crontab) FIRST # -############################################ -for SERVER in "${FIRST[@]}"; do - echo "------------------------------------" - date +"%H:%M:%S %d-%m-%Y" - echo "Starting reboot of $SERVER" - ssh "$SERVER" reboot now - sleep 60 -done - -############################################ -# 1:15h SECOND # -############################################ -timeNow=$(date +%s) -targetTime=$(date -d 01:15 +%s) -timeToWait=($targetTime - $timeNow) -echo "Waiting $timeToWait seconds" -sleep "$timeToWait" - -for SERVER in "${SECOND[@]}"; do - echo "------------------------------------" - date +"%H:%M:%S %d-%m-%Y" - echo "Starting reboot of $SERVER" - ssh "$SERVER" reboot now - sleep 60 -done - -############################################ -# 1:30h THIRD # -############################################ -timeNow=$(date +%s) -targetTime=$(date -d 01:30 +%s) -timeToWait=($targetTime - $timeNow) -echo "Waiting $timeToWait seconds" -sleep $timeToWait - -for SERVER in "${THIRD[@]}"; do - echo "------------------------------------" - date +"%H:%M:%S %d-%m-%Y" - echo "Starting reboot of $SERVER" - ssh "$SERVER" reboot now -done - -############################################ -# 1:45h REST # -############################################ -timeNow=$(date +%s) -targetTime=$(date -d 01:45 +%s) -timeToWait=($targetTime - $timeNow) -echo "Waiting $timeToWait seconds" -sleep $timeToWait - -for SERVER in "${REST[@]}"; do - echo "------------------------------------" - date +"%H:%M:%S %d-%m-%Y" - echo "Starting reboot of $SERVER" - ssh "$SERVER" reboot now -done - -############################################ -# 1:55h CUSTOM # -############################################ -timeNow=$(date +%s) -targetTime=$(date -d 01:55 +%s) -timeToWait=($targetTime - $timeNow) -echo "Waiting $timeToWait seconds" -sleep $timeToWait -echo "------------------------------------" -date +"%H:%M:%S %d-%m-%Y" -echo "Starting reboot of $(hostname)" -shutdown -r 5 "Reboot in 5 minutes." +#!/bin/bash + +# Zie ook https://wiki.de-roo.org/doku.php/cron + +FIRST=("fs01") +SECOND=("web06" "web03" "net04") +THIRD=("net02" "net03" "net05" ) +REST=("dt03" "git01" "run01" "has01" "iam01" "man01" "mdm01" "minecraft" "nms01" "pbx01" "rpi03" "web04" "web05" "web07" "mail02" "cloud01" "srv01" "siem01" "web08" "web09" "dms01") +timeToWait=900 + +############################################ +# 1:00h (uit crontab) FIRST # +############################################ +for SERVER in "${FIRST[@]}"; do + echo "------------------------------------" + date +"%H:%M:%S %d-%m-%Y" + echo "Starting reboot of $SERVER" + ssh "$SERVER" reboot now + sleep 60 +done + +############################################ +# 1:15h SECOND # +############################################ +echo "Waiting $timeToWait seconds" +sleep "$timeToWait" + +for SERVER in "${SECOND[@]}"; do + echo "------------------------------------" + date +"%H:%M:%S %d-%m-%Y" + echo "Starting reboot of $SERVER" + ssh "$SERVER" reboot now + sleep 60 +done + +############################################ +# 1:30h THIRD # +############################################ +echo "Waiting $timeToWait seconds" +sleep $timeToWait + +for SERVER in "${THIRD[@]}"; do + echo "------------------------------------" + date +"%H:%M:%S %d-%m-%Y" + echo "Starting reboot of $SERVER" + ssh "$SERVER" reboot now +done + +############################################ +# 1:45h REST # +############################################ +echo "Waiting $timeToWait seconds" +sleep $timeToWait + +for SERVER in "${REST[@]}"; do + echo "------------------------------------" + date +"%H:%M:%S %d-%m-%Y" + echo "Starting reboot of $SERVER" + ssh "$SERVER" reboot now +done + +############################################ +# 1:55h CUSTOM # +############################################ +echo "Waiting $timeToWait seconds" +sleep $timeToWait +echo "------------------------------------" +date +"%H:%M:%S %d-%m-%Y" +echo "Starting reboot of $(hostname)" +shutdown -r 5 "Reboot in 5 minutes."