Weather:suny
一、需求:bash
[root@Dasoncheng sbin]# cat r.sh #!/bin/bash ##to test the network card liuliang if [ -n "$1" ]; then if `sar -n DEV 1 2 | tail -3 | grep -q "$1"`; then ab=`sar -n DEV 1 2 |tail -3 |grep eth0 |awk '{print $5,$6}'` a=`echo $ab |awk '{print $1}'` b=`echo $ab |awk '{print $2}'` if [ "$a" == "0.00" ] && [ "$b" == "0.00" ]; then ifdown $1 ifup $1 else exit fi else echo "Please input a vaild network card!" fi else echo "Sorry you need to input the name of network card!" fi
#!/bin/bash LANG=en n1=`sar -n DEV 1 60 |grep eth0 |grep -i average|awk '{print $5}'|sed 's/\.//g'` n2=`sar -n DEV 1 60 |grep eth0 |grep -i average|awk '{print $6}'|sed 's/\.//g'` if [ $n1 == "000" ] && [ $n2 == "000" ] then ifdown eth0 ifup eth0 fi ##而後寫個cron,10分鐘執行一次