Thursday, August 1, 2013

Script to shutdown all Linux machines in network

Use the below shell script to shutdown all Linux systems in LAN.

This shell script will be useful for system admins.


#!/bin/sh
read -p "Do you want to shutdown all systems? (y/n)" OUT
if [ "$OUT" = "y" ] || [ "$OUT" = "Y" ]; then
sys_ip="11 12 13"
for i in $sys_ip; do
if ping -c 1 "192.168.2.$i">/dev/null 2>&1; then
ssh root@192.168.2.$i init 0
else
echo "192.168.2.$i system is already down"
fi
done
elif [ "$OUT" = "n" ] || [ "$OUT" = "N" ]; then
 echo "Okay. No problem. You can shutdown it later."
else
 echo "You have entered wrong character. Enter only y or n."
fi

No comments:

Post a Comment