OpenWrt 定期检测进程是否存在并重启

 脚本很简单,就下面几行:

#!/bin/sh

# c3h 为要检测的进程
process=`ps | grep c3h`;
  
if [ "$process" == "" ]; then
    # 重启进程
    /usr/bin/c3h 学号 密码 eth0.2 &
    echo "C3H restarted";
else
    echo "C3H process exsits";
fi

    保存之后(我保存在 /usr/bin 下,文件名为 restart-c3h )给它运行权限:

chmod +x /usr/bin/restart-c3h

    然后把定时任务那里加一条,让这个脚本在 星期一至五 早上 7:10 启动一次:

10 7 * * 1-5 /usr/bin/restart-c3h

 http://www.openwrt.pro/post-115.html

原文地址:https://www.cnblogs.com/7qin/p/13584852.html