您的位置:首页 > 运维架构 > Linux

linux 判断某个进程是否存在,存在则重启,不存在则启动。

2017-12-29 11:26 399 查看
++++++++++++++++++++++++++++++++++++ PIDS=`ps -ef|grep "app.js"|grep -v grep`

if [ "$PIDS" != "" ]; thenpm2 restart appecho "app restart!"elsepm2 start app.jsecho "app started"fi

+++++++++++++++++++++++++++++++++++

## 下面是node环境 webhook脚本配置

#!/bin/bash

export NODE_HOME=/usr/bin/nodeexport PATH=$NODE_HOME/bin:$PATHecho "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"cd /www/wwwroot/api/nodeApi/git reset --hard origin/mastergit clean -fgit pullPIDS=`ps -ef|grep "app.js"|grep -v grep`if [ "$PIDS" != "" ]; thenpm2 restart appecho "app restart!"elsepm2 start app.jsecho "app started"fipm2 show 0echo "----------------------------------------------------------------------------"
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: