腳本比較簡單,可以判斷服務器是否開機。
#!/bin/bash
#Checks to see if hosts 192.168.1.1-192.168.1.255 are alive
for n in {1..200}; do
host=192.168.1.$n
ping -c2 $host &>/dev/null
if [ $? = 0 ]; then
echo "$host is UP"
else
echo "$host is DOWN"
fi
done