守护进程脚本

最后更新于:2022-04-02 03:47:43

[TOC] ## code
uporgserver_guard ``` #!/bin/bash cd $(dirname ${0}) while [ 2 -ge 1 ]; do ./uporgserver_starter > /dev/null 2>&1 sleep 30 done exit 0 ```

uporgserver_starter ``` #!/bin/bash cd $(dirname ${0}) APP_NAME="UpOrgServer" if [[ $(ps -ef | grep -v 'grep' | grep "$APP_NAME" |wc -l) -ge 1 ]]; then echo "${APP_NAME} is already running." else nohup ./${APP_NAME} > /dev/null 2>&1 & echo "${APP_NAME} is starting ..." sleep 1 fi exit 0 ```

';