Linux下部署Java项目(jetty作为容器)常用脚本命令

startup.sh

#!/bin/bash

echo $(basename $(pwd)) "jetty started"
cd jetty
nohup java -Xmx8g -Xms8g -Xmn4g -XX:PermSize=2g -XX:MaxPermSize=4g -XX:+CMSClassUnloadingEnabled -jar -Dfile.encoding=UTF-8 start.jar --module=http >/dev/null 2>&1 &

status.sh

#!/bin/bash

#close start.jar and debug
for pid in `ps aux | grep java | grep -v "grep" | awk '{print $2}'` ;
do
        start_path=`ls -l /proc/${pid}/cwd | awk '{print $11}'`
        if [[ ${start_path} =~ $(basename $(pwd)) ]]
        then
                debug_path=`ps aux | grep -v grep |grep ${pid}|awk '{print $12}'`
                if [[ ${debug_path} =~ "debug" ]]
                then
                        echo ${pid} $(basename $(pwd)) "java debug is running."
                else
                        echo ${pid} $(basename $(pwd)) "java is running."
                fi
        fi
done

stop.sh

#!/bin/bash

#close start.jar and debug
for pid in `ps aux | grep java | grep -v "grep" | awk '{print $2}'` ;
do
        start_path=`ls -l /proc/${pid}/cwd | awk '{print $11}'`
        if [[ ${start_path} =~ $(basename $(pwd)) ]]
        then
                debug_path=`ps aux | grep -v grep |grep ${pid}|awk '{print $12}'`
                if [[ ${debug_path} =~ "debug" ]]
                then
                        echo ${pid} $(basename $(pwd)) "java debug killed"
                else
                        echo ${pid} $(basename $(pwd)) "java killed"
                fi
                kill -9 ${pid}
        fi
done
posted @ 2019-12-03 17:05  量化未来  阅读(546)  评论(1编辑  收藏  举报