使用shell脚本简单的为进程保活(自动拉起) 之前有一个测试程序,会异常退出。so谷歌了一下,写了一个脚本每30s判定一下进程是否存在,如不存在就自动拉起来。 ```bash #!/bin/sh while true do process=`ps aux | grep talos_agent | grep -v grep`; if [ "$process" == "" ]; then sleep 30; echo "process 不存在,开始执行"; ./talos_agent 2>> ./logs/stderr.log 1>> /dev/null; else sleep 30; echo "process exsits"; fi done ``` 好简单 来自 大脸猪 写于 2022-03-23 19:54 -- 更新于2022-03-23 19:55 -- 0 条评论