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

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

 

相关文章:

  • 2022-12-23
  • 2021-11-20
  • 2022-01-10
  • 2021-12-25
  • 2022-12-23
  • 2021-10-09
  • 2021-05-21
  • 2021-10-08
猜你喜欢
  • 2021-11-17
  • 2022-01-30
  • 2022-12-23
  • 2021-04-28
  • 2021-11-03
  • 2022-12-23
相关资源
相似解决方案