Centos7 启动脚本

启动脚本、如果进程已存在,输出错误信息后退出;

#! /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"

 

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。
扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄