---
title: "shell脚本判断进程是否存在并重启"
author: "maxer025"
date: "2016-04-07T11:00:17Z"
tags: []
categories: ["移动开发"]
slug: "shell"
draft: false
lastmod: "2016-04-07T11:00:17Z"
id: 2289204
url: "https://maxer025.iteye.com/blog/2289204"
---

#!/bin/bash
#
 cd /opt/rms/mobileServer
 export PATH=/opt/rms/nodejs010/bin:$PATH
 export LD_LIBRARY_PATH=/usr/lib/oracle/12.1/client64/lib:$LD_LIBRARY_PATH

 count=`ps -ef |grep mobileServer.js |grep -v "grep" |wc -l`
# echo $?
echo $count
if  ; then
      echo "start process......"
     # cd /opt/rms/mobileServer
      #scl enable nodejs010 bash
     # export PATH=/opt/rms/nodejs010/bin:$PATH
      echo "start to run command.."
     # export LD_LIBRARY_PATH=/usr/lib/oracle/12.1/client64/lib:$LD_LIBRARY_PATH
      nohup  node  /opt/rms/mobileServer/mobileServer.js &
      echo "commands finished..."
else
        echo "runing..."
  fi

engrmsapptst1:/home/engrms>