ubuntu 守护进程
#!/bin/bash
# 定义所守护的进程名称或关键字
TARGET_PROCESS="AppRun"
while true; do
# 检测目标进程是否运行
if pgrep -x "$TARGET_PROCESS" >/dev/null; then
echo "The process is running."
else
# 启动你的项目运行脚本
/home/user/RadioFinder/start.sh &
# 记录守护进程重启的日志
echo "Restarting the project at $(date)" >> daemon_log.txt
fi
# 等待一段时间后重新检测,可以根据需要调整
sleep 1
done