diff --git a/rebootSchedule.sh b/rebootSchedule.sh index b10d4cd..274abfc 100644 --- a/rebootSchedule.sh +++ b/rebootSchedule.sh @@ -10,11 +10,11 @@ REST=("dt03" "git01" "run01" "has01" "iam01" "man01" "mdm01" "minecraft" "nms01" ############################################ # 1:00h (uit crontab) FIRST # ############################################ -for SERVER in ${FIRST[@]}; do +for SERVER in "${FIRST[@]}"; do echo "------------------------------------" date +"%H:%M:%S %d-%m-%Y" - echo Starting reboot of $SERVER - ssh $SERVER reboot now + echo "Starting reboot of $SERVER" + ssh "$SERVER" reboot now sleep 60 done @@ -23,15 +23,15 @@ done ############################################ timeNow=$(date +%s) targetTime=$(date -d 01:15 +%s) -timeToWait=$(($targetTime - $timeNow)) -echo Waiting $timeToWait seconds -sleep $timeToWait +timeToWait=($targetTime - $timeNow) +echo "Waiting $timeToWait seconds" +sleep "$timeToWait" -for SERVER in ${SECOND[@]}; do +for SERVER in "${SECOND[@]}"; do echo "------------------------------------" date +"%H:%M:%S %d-%m-%Y" - echo Starting reboot of $SERVER - ssh $SERVER reboot now + echo "Starting reboot of $SERVER" + ssh "$SERVER" reboot now sleep 60 done @@ -40,15 +40,15 @@ done ############################################ timeNow=$(date +%s) targetTime=$(date -d 01:30 +%s) -timeToWait=$(($targetTime - $timeNow)) -echo Waiting $timeToWait seconds +timeToWait=($targetTime - $timeNow) +echo "Waiting $timeToWait seconds" sleep $timeToWait -for SERVER in ${THIRD[@]}; do +for SERVER in "${THIRD[@]}"; do echo "------------------------------------" date +"%H:%M:%S %d-%m-%Y" - echo Starting reboot of $SERVER - ssh $SERVER reboot now + echo "Starting reboot of $SERVER" + ssh "$SERVER" reboot now done ############################################ @@ -56,15 +56,15 @@ done ############################################ timeNow=$(date +%s) targetTime=$(date -d 01:45 +%s) -timeToWait=$(($targetTime - $timeNow)) -echo Waiting $timeToWait seconds +timeToWait=($targetTime - $timeNow) +echo "Waiting $timeToWait seconds" sleep $timeToWait -for SERVER in ${REST[@]}; do +for SERVER in "${REST[@]}"; do echo "------------------------------------" date +"%H:%M:%S %d-%m-%Y" - echo Starting reboot of $SERVER - ssh $SERVER reboot now + echo "Starting reboot of $SERVER" + ssh "$SERVER" reboot now done ############################################ @@ -72,10 +72,10 @@ done ############################################ timeNow=$(date +%s) targetTime=$(date -d 01:55 +%s) -timeToWait=$(($targetTime - $timeNow)) -echo Waiting $timeToWait seconds +timeToWait=($targetTime - $timeNow) +echo "Waiting $timeToWait seconds" sleep $timeToWait echo "------------------------------------" date +"%H:%M:%S %d-%m-%Y" -echo Starting reboot of $(hostname) +echo "Starting reboot of $(hostname)" shutdown -r 5 "Reboot in 5 minutes."