博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
springboot linux下启动的脚本
阅读量:6818 次
发布时间:2019-06-26

本文共 1998 字,大约阅读时间需要 6 分钟。

hot3.png

看到比较好的linux脚本:

start.sh

#!/bin/shrm -f tpidnohup java -jar xx.jar --spring.profiles.active=dev > /dev/null 2>&1 &echo $! > tpidecho Start Success!

stop.sh

#!/bin/shAPP_NAME=myapptpid=`ps -ef|grep $APP_NAME|grep -v grep|grep -v kill|awk '{print $2}'`if [ ${tpid} ]; then    echo 'Stop Process...'    kill -15 $tpidfisleep 5tpid=`ps -ef|grep $APP_NAME|grep -v grep|grep -v kill|awk '{print $2}'`if [ ${tpid} ]; then    echo 'Kill Process!'    kill -9 $tpidelse    echo 'Stop Success!'fi

check.sh

#!/bin/shAPP_NAME=myapptpid=`ps -ef|grep $APP_NAME|grep -v grep|grep -v kill|awk '{print $2}'`if [ ${tpid} ]; then        echo 'App is running.'else        echo 'App is NOT running.'fi

kill.sh

#!/bin/shAPP_NAME=myapptpid=`ps -ef|grep $APP_NAME|grep -v grep|grep -v kill|awk '{print $2}'`if [ ${tpid} ]; then    echo 'Kill Process!'    kill -9 $tpidfi

 

以上合并为一个脚本:

#!/bin/shAPP=stockhouseAPP_NAME=${APP}".jar"command=$1function start(){  rm -f tpid  nohup java -jar ${APP_NAME} > /dev/null 2>&1 &  echo $! > tpid  check}function stop(){  tpid=`ps -ef|grep $APP_NAME|grep -v grep|grep -v kill|awk '{print $2}'`  if [ ${tpid} ]; then     echo 'Stop Process...'     kill -15 $tpid   fi   sleep 5   tpid=`ps -ef|grep $APP_NAME|grep -v grep|grep -v kill|awk '{print $2}'`   if [ ${tpid} ]; then      echo 'Kill Process!'      kill -9 $tpid    else      echo 'Stop Success!'    fi}function check(){   tpid=`ps -ef|grep $APP_NAME|grep -v grep|grep -v kill|awk '{print $2}'`   if [ ${tpid} ]; then       echo 'App is running.'   else       echo 'App is NOT running.'   fi}function forcekill(){  tpid=`ps -ef|grep $APP_NAME|grep -v grep|grep -v kill|awk '{print $2}'`  if [ ${tpid} ]; then     echo 'Kill Process!'     kill -9 $tpid  fi}if [ "${command}" ==  "start" ]; then    startelif [ "${command}" ==  "stop" ]; then     stopelif [ "${command}" ==  "check" ]; then     checkelif [ "${command}" ==  "kill" ]; then     forcekillelse    echo "Unknow argument...."fi

 

 

转载于:https://my.oschina.net/huhaoren/blog/1794122

你可能感兴趣的文章
如何在直播中解决黑屏、花屏、闪屏问题 | 直播疑难杂症排查
查看>>
js获取浏览器高度和宽度值(多浏览器)
查看>>
Deep learning:十六(deep networks)
查看>>
▲移动web前端开发
查看>>
LeetCode: Palindrome Partition
查看>>
推荐使用C++ 11
查看>>
C#中的接口
查看>>
osg学习示例之遇到问题四骨骼动画编译osgCal
查看>>
Vue 实例暴露了一些有用的实例属性与方法。这些属性与方法都有前缀 $,以便与代理的 data 属性区分...
查看>>
站立会议(2)
查看>>
HDU 1018 Big Number(数论,Stirling公式)
查看>>
从零开始做SSH项目(二)
查看>>
spring ioc aop 理解
查看>>
222
查看>>
在使用react时的异步问题解决
查看>>
Java调用solrj5.5.3接口,查询数据
查看>>
Python中的logging模块
查看>>
plink, vcftool计算等位基因频率(allele frequency,vcf)
查看>>
变量和赋值
查看>>
mysql的优化
查看>>