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


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

PIDS=`ps -ef|grep "app.js"|grep -v grep`

if [ "$PIDS" != "" ]; then
pm2 restart app
echo "app restart!"
else
pm2 start app.js
echo "app started"
fi

 

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

 

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

#!/bin/bash

 

export NODE_HOME=/usr/bin/node
export PATH=$NODE_HOME/bin:$PATH
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
cd /www/wwwroot/api/nodeApi/
git reset --hard origin/master
git clean -f
git pull
PIDS=`ps -ef|grep "app.js"|grep -v grep`
if [ "$PIDS" != "" ]; then
pm2 restart app
echo "app restart!"
else
pm2 start app.js
echo "app started"
fi
pm2 show 0
echo "----------------------------------------------------------------------------"


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM