在你的shell脚本开始加上
##################
. /etc/profile
. ~/.bash_profile
##################
#!/bin/bash
##################
. /etc/profile
. ~/.bash_profile
##################
lan_eth=`netstat -ni |awk '{print $1'}|grep -Ev 'lo|Iface|Kernel|bond'`
for i in $lan_eth
do
& nbsp; lan_status=`ethtool $i |grep Link |awk '{ print $3 }'`
& nbsp; if [ x$lan_status != xyes ] ; then
& nbsp; /usr/sbin/ethtool $i
& nbsp; echo -e "检查结果: $i 网卡状态不正常!"
& nbsp; else
& nbsp; /usr/sbin/ethtool $i
& nbsp; echo -e "检查结果: $i 网卡状态正常! "
& nbsp; fi
done
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/21813517/viewspace-1221263/
,如需转载,请注明出处,否则将追究法律责任。