Centos7 啓動腳本

Centos7 啓動腳本

啓動腳本、若是進程已存在,輸出錯誤信息後退出;node

#! /bin/bash

PIDS=`ps -ef | grep '/usr/bin/node ./index.js' | grep '?' | awk '{print $2}'`
if [ -n "$PIDS" ]; then
   echo "ERROR: The index.js (user async service) already started!"
   echo "PID: $PIDS"
   exit 1
fi

echo 'start index.js ...'
cd /myservice
./nohup index.js 2>&1>/dev/null &

sleep 3

str=$"\n"
sstr=$(echo -e $str)
echo $sstr
echo "start index.js success"
相關文章
相關標籤/搜索