shell 启动java

2021-01-07  本文已影响0人  HaoDongZ

#!/bin/bash
DIR="cd /opt/xxx/xxx"
APP_NAME="xxx-xxx-xxx-boot-1.0-SNAPSHOT.jar"
case $1 in
    start)
    nohup   /opt/jdk1.8/bin/java -jar -Xms256m -Xmx256m -XX:-HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=./logs -Dspring.profiles.active=uat ${DIR}${APP_NAME} > /dev/null &
        echo ${APP_NAME} start!
        ;;
    stop)
        ps -ef| grep ${APP_NAME} |grep -v grep |awk '{print $2}'  | sed -e "s/^/kill -9 /g" | sh -
        echo ${APP_NAME} stop!
        ;;
    restart)
        "$0" stop
        sleep 3
        "$0" start
        ;;
    status)  ps -aux | grep ${APP_NAME} | grep -v 'grep'
        ;;
    log)
    case $2 in
debug)
tail -f -n ${3-400} logs/debug.log
;;
error)
tail -f -n ${3-400} logs/error.log
;;
*)
echo "Example: services.sh log {debug|error}" ;;
esac
        ;;
    *)
        echo "Example: services.sh [start|stop|restart|status]" ;;
esac

上一篇下一篇

猜你喜欢

热点阅读