找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
广告投放联系QQ68610888
查看: 4968|回复: 4

openwrt如何运行脚本

[复制链接]
有一个“operation.sh”的脚本已经通过winSCP上传到路由器/tmp,但不知道怎么执行
我的恩山、我的无线 The best wifi forum is right here.
cd /tmp
sh operation.sh

点评

#!/bin/sh # 自动检查线路是否正常,不正常就重启 Openwrt 重新拨号 PING=`ping -c 5 202.96.128.86|grep -v grep|grep '64 bytes' |wc -l` if [ ${PING} -ne 0 ];then exit 0 else /etc/init.d/network  详情 回复 发表于 2020-4-13 03:04
这个脚本我无论如何都不知道怎么运行  详情 回复 发表于 2020-4-13 03:03
#!/bin/sh #sleep 100 DATE=`date +%Y-%m-%d-%H:%M:%S` tries=0 echo --- my_watchdog start --- while [[ $tries -lt 5 ]] do if /bin/ping -c 1 114.114.114.114 >/dev/null then  详情 回复 发表于 2020-4-13 03:02
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

Spcn 发表于 2019-8-10 17:36
cd /tmp
sh operation.sh

#!/bin/sh
#sleep 100
DATE=`date +%Y-%m-%d-%H:%M:%S`
tries=0
echo --- my_watchdog start ---
while [[ $tries -lt 5 ]]
do
        if /bin/ping -c 1 114.114.114.114 >/dev/null
        then
                echo --- exit ---
#               echo $DATE OK >>my_watchdog.log
                exit 0
        fi
        tries=$((tries+1))
        sleep 10
#       echo $DATE tries: $tries >>my_watchdog.log
done

echo $DATE network restart >>my_watchdog.log
/etc/init.d/network restart

#echo $DATE reboot >>my_watchdog.log
#reboot


二、然后用crontab -e来在系统的crontab中添加一句,每隔5分钟定时运行这个脚本:

*/5 * * * * sh /root/my_watchdog.sh
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

Spcn 发表于 2019-8-10 17:36
cd /tmp
sh operation.sh

这个脚本我无论如何都不知道怎么运行
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

Spcn 发表于 2019-8-10 17:36
cd /tmp
sh operation.sh

#!/bin/sh
# 自动检查线路是否正常,不正常就重启 Openwrt 重新拨号

PING=`ping -c 5 202.96.128.86|grep -v grep|grep '64 bytes' |wc -l`

if [ ${PING} -ne 0 ];then
        exit 0
else
        /etc/init.d/network restart
fi

sleep 10

PING2=`ping -c 5 202.96.128.86|grep -v grep|grep '64 bytes' |wc -l`

if [ ${PING2} -ne 0 ];then
        exit 0
else
        reboot
fi

光找到代码了,但是怎么用都不知道,搞了几天都不行
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

欢迎大家光临恩山无线论坛上一条 /1 下一条

有疑问请添加管理员QQ86788181|手机版|小黑屋|Archiver|恩山无线论坛(常州市恩山计算机开发有限公司版权所有) ( 苏ICP备05084872号 )

GMT+8, 2024-4-29 17:02

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

| 江苏省互联网有害信息举报中心 举报信箱:js12377 | @jischina.com.cn 举报电话:025-88802724 本站不良内容举报信箱:68610888@qq.com 举报电话:0519-86695797

快速回复 返回顶部 返回列表