springboot项目启动.sh配置,配置开机启动

1 篇文章 0 订阅
1 篇文章 0 订阅

原文地址:https://blog.csdn.net/zhuchunyan_aijia/article/details/53811368

xxx.sh

文中. /etc/profile需要注意添加

#!/bin/sh

#nohup java  -Xbootclasspath/a:./config -Dloader.path=.,lib -jar $APP_NAME --logging.config=./config/logback.xml >/dev/null 2>&1 &

#这里可替换为你自己的执行程序,其他代码无需更改
APP_NAME=hg-zhwg-web-1.0.0.jar

#启动方法
start(){
    pid=`ps -ef|grep $APP_NAME|grep -v grep|awk '{print $2}'`
        if [ "$pid" ]; then
        echo "$APP_NAME is already running. pid=$pid ."
    else
		. /etc/profile
        nohup java -jar -Dloader.path=.,lib $APP_NAME --logging.config=./config/log4j2.xml >/dev/null 2>&1 &
        echo "$APP_NAME now is running"
    fi
}
#停止方法
stop(){
    pid=`ps -ef|grep $APP_NAME|grep -v grep|awk '{print $2}'`
    if [ "$pid" ]; then
        kill -9 $pid
        echo "Pid:$pid stopped"
    else
        echo "$APP_NAME is not running"
    fi
}
#输出运行状态
status(){
    pid=`ps -ef|grep $APP_NAME|grep -v grep|awk '{print $2}'`
    if [ "$pid" ]; then
        echo "$APP_NAME is running. Pid is ${pid}"
    else
        echo "$APP_NAME is NOT running."
    fi
}
#根据输入参数,选择执行对应方法,不输入则执行使用说明
case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    status)
        status
        ;;
    restart)
        stop
        sleep 5
        start
        ;;
    *)
        echo "Usage:{start|stop|status|restart}"
        ;;
esac
exit 0

在/etc/init.d下新建文件
my.sh

chkconfig --add my (首先,添加为系统服务,注意add前面有两个横杠)
chkconfig my on (开机自启动)
chkconfig --list (列表显示)
service my start(启动服务,就是执行my的脚本)

#!/bin/bash
#
# kenny kenny.zhou@tom.com
# /etc/rc.d/init.d/hgzhwg
# init script for hgzhwg precesses
#
# processname: hgzhwg
# description: hgzhwg is a j2se server
# chkconfig: 2345 86 16
# description: Start up the hgzhwg servlet engine.

RETVAL=$?

case "$1" in
start)
echo $"Starting hgzhwg"
cd /home/xxxx/install/springboot
./xxx.sh restart
;;
stop)
echo $"Stopping Tomcat"
;;
*)
echo $"Usage: $0 {start|stop}"
exit 1
;;
esac

exit $RETVAL
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值