ITPub博客

首页 > Linux操作系统 > Linux操作系统 > linux shell 2

linux shell 2

原创 Linux操作系统 作者:upup1983 时间:2007-05-10 09:58:26 0 删除 编辑
#!/bin/bash
#------------------------------------
#------------------------------------
# Functions of this programe:
# Prospect the access point address once every one minute(command:crontab).
# If any difference occures,
# it will post the ping command on the server
# and if packet loss rate reaches 100%,
# it will restart the network.
#-----------------------------------
#-----------------------------------
/sbin/iwconfig eth0|grep Point|awk '{print $5}' > /home/mac_new 2>/dev/null
if [ `cat /home/mac_new` = `cat /home/mac_old` 2>/dev/null ]
then
echo `date`>>/home/iwconfig_mac.log
echo same_mac>>/home/iwconfig_mac.log
else
(
echo `date`>>/home/iwconfig_mac.log
echo different_mac>>/home/iwconfig_mac.log
cat /home/mac_new > /home/mac_old 2>/dev/null
i=1
for loop in 1 2
do
(
i=$(($i+1))
if [ `ping -c 3 12.0.0.1|grep loss|awk '{print $7}'` < "100%" 2>/dev/null ]
then
echo `date`>>/home/netstate.log
echo "packet loss < 100%">>/home/netstate.log
else
echo `date`>>/home/netstate.log
echo "packet loss = 100%">>/home/netstate.log
/etc/rc.d/init.d/network restart >> /home/netstate.log 2>/dev/null
fi
)
done
)
fi
----------------------
----------------------
crontab:
* * * * * /home/netwk
* * * * * (sleep 30 && /home/netwk)[@more@]

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/9721529/viewspace-914321/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2009-03-09

  • 博文量
    43
  • 访问量
    792371