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