#!/bin/bash pkg=$1 env="dev" dt=$(date +"%Y%m%d%H%M%S") log="$pkg-$dt" scirpt_pid=$$ pid=`ps -ef | grep cbrain-execute | grep -Ev "grep|$scirpt_pid" | awk '{print $2}'` if [ -z "$pid" ]; then echo "no $pkg process running" else echo "exist pid: "$pid kill -9 $pid echo "killed: "$pid fi nohup java -jar -Dspring.profiles.active=$env $pkg > $log.txt 2>&1 & nowpid=`ps -ef |grep $pkg| grep -Ev "grep|$scirpt_pid" |awk '{print $2}'` echo "************ 应用启动,pid:$nowpid **************" tail -f $log.txt