shell脚本记录

it2024-12-02  16

#!/bin/bash export BUILD_ID=DONTKILLME APP_NAME=$2 ENV_PROFILE=$3 function stop(){ PID=`ps -ef|grep $APP_NAME|grep -v grep|grep -v springboot.sh|awk '{print $2}'` if [[ -n "$PID" ]];then echo 'Stop Process...' kill -15 $PID fi PID=`ps -ef|grep $APP_NAME|grep -v grep|grep -v springboot.sh|awk '{print $2}'` if [[ -n "$PID" ]];then echo "PID: $PID" echo 'Kill Process!.....' kill -9 $PID else echo 'No pid, No process,Stop Success!....' fi } function start(){ # java -version # if [ $? = 0 ];then JAVA_OPTS=" -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true " JAVA_MEM_OPTS=" -server -Xmx512m -Xms512m -Xmn256m -XX:PermSize=128m -Xss256k -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSCompactAtFullCollection -XX:LargePageSizeInBytes=128m -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70 " nohup java $JAVA_OPTS $JAVA_MEM_OPTS -jar -Dspring.profiles.active=$ENV_PROFILE ${APP_NAME}.jar > /dev/null 2>&1 & #nohup java $JAVA_OPTS $JAVA_MEM_OPTS -jar ${APP_NAME}.jar --spring.config.location=config/application.yml --spring.config.location=config/log4j.properties > /dev/null 2>&1 & echo $! $? echo Start Success! # else # echo "java is not installed" # fi } function status(){ PID=`ps -ef|grep $APP_NAME|grep -v grep|grep -v springboot.sh|awk '{print $2}'` if [[ -n "$PID" ]]; then echo "PID:$PID" echo "$APP_NAME is running." else echo "$APP_NAME is downing." fi } ## 入口 case $1 in start) start ;; stop) stop ;; status) status ;; *) echo "./springboot.sh start/stop/status" ;; esac exit 0
最新回复(0)