五、自动监控ADSL并重拔号的shell脚本

公司办公室的adsl爱掉线,一掉的话网关的gateway就没了。因此编写了下列脚本:

#!/bin/bash
while :
do
if route | tail -l | grep "0.0.0.0"
then
&>/dev/null
else
adsl-stop
adsl-start
fi
sleep 10
done

执行脚本方法: nuhup sh route.sh &

注意前面要用上nohup,这样避免root用户logout时此脚本也退出生效的问题。


相关内容