脚本比较简单,可以判断服务器是否开机。 #!/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 ech
脚本比较简单,可以判断服务器是否开机。
#!/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
(文章内容如有侵权,敬请来信告知,我们将及时撤销)