linux应用程序崩溃如何启动

2022-02-21 11:27:11 星期一
linux如何让一个程序崩溃后自动重启

watchdog.sh
#!/bin/bash
while true
do
    ps -ef | grep "程序名" | grep -v "grep"
    if [ "$?" -eq 1 ]
        then
        ./run.sh #启动应用,修改成自己的启动应用脚本或命令
        echo "process has been restarted!"
    else
        echo "process already started!"
    fi
    sleep 10
done

2022-02-21 11:27:53 星期一
使用Linux C编写看门狗(watchdog)程序


posted @ 2022-02-21 11:29  上官鸿信の  阅读(101)  评论(0编辑  收藏  举报