脚本比较简单,可以判断服务器是否开机。
#!/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
时间: 2024-11-02 12:52:05