最近网络总是不知道什么时候就连不上了,必须重启或者重新拨号才行。所有就想能不能用命令实现呢?
所见就上网络搜索下。还真有。,整理出来以后留着用吧。while [ 1 ]
do
ping -c 1 www.baidu.com
if ( $? ! -eq 0)
wifi down && wifi up # 重启wifi
/etc/init.d/network restart #重启网络进程
reboot # 重启路由
fi
sleep 5
done
ps:本人设置的是每天早上三点自动重启,命令设置如下,具体的其他时间设置可以参考如下:
0 3 * * * /sbin/reboot
下面是一些切得例子可以参考一下:00 22 * * * /usr/local/etc/rc.d/lighttpd restart
每晚的22点重启apache。30 3 1,10,20 * * /usr/local/etc/rc.d/lighttpd restart
每月1、10、20日的3 : 30重启apache。10 1 * * 6,0 /usr/local/etc/rc.d/lighttpd restart
每周六、周日的1 : 10重启apache。0,30 18-23 * * * /usr/local/etc/rc.d/lighttpd restart
每天18 : 00至23 : 00之间每隔30分钟重启apache。0 23 * * 6 /usr/local/etc/rc.d/lighttpd restart
每星期六的11 : 00 pm重启apache。
* */1 * * * /usr/local/etc/rc.d/lighttpd restart
每一小时重启apache* 23-7/1 * * * /usr/local/etc/rc.d/lighttpd restart
晚上11点到早上7点之间,每隔一小时重启apache0 11 4 * mon-wed /usr/local/etc/rc.d/lighttpd restart
每月的4号与每周一到周三的11点重启apache0 4 1 jan * /usr/local/etc/rc.d/lighttpd restart
一月一号的4点重启apache