springboot 启动脚本
1 #!/bin/bash 2 3 cd `dirname $0` 4 data_dir=`pwd` 5 JAVA_HOME=/usr/local/jdk1.8.0_92 6 logs_dir=$data_dir/logs 7 if [ ! -d $logs_dir ]; then 8 mkdir $logs_dir 9 fi 10 11 PID=`ps -ef | grep -w xxx | grep -v grep | grep -v bash |awk '{print $2}'` 12 13 14 if [ -n "$PID" ] 15 then kill -9 $PID 16 echo "before: $PID" 17 nohup $JAVA_HOME/bin/java -jar $data_dir/xxx.jar >> /dev/null 2>&1 & 18 sleep 3 19 P=`ps -ef | grep -w xxx | grep -v grep | grep -v bash |awk '{print $2}'` 20 echo "now : $P" 21 else 22 echo "starting" 23 nohup $JAVA_HOME/bin/java -jar $data_dir/xxx.jar >> /dev/null 2>&1 & 24 P=`ps -ef | grep -w xxx | grep -v grep | grep -v bash |awk '{print $2}'` 25 echo "now : $P" 26 fi