#!/bin/sh
APP_NAME=*.jar
LOG_PATH=./logs
#使用说明,用来提示输入参数
usage() {
echo "Usage: sh ${APP_NAME} [start|stop|restart|status]"
exit 1
}
#检查程序是否在运行
is_exist() {
pid=`ps -ef | grep $APP_NAME | grep -v grep | awk '{print $2}' `
echo "pid==${pid}"
#如果不存在返回1,存在返回0
if [ -z "${pid}" ]; then
return 1
else
return 0
fi
}
#启动方法
start() {
echo "*********check is_exist in first*****"
is_exist
if [ $? -eq "0" ]; then
echo "${APP_NAME} is already running. pid=${pid} ."
kill $pid
sleep 5s
kill -9 $pid
echo "kill pid " $pid
else
echo "${APP_NAME} is not running and pid is null ."
nohup java -jar $APP_NAME >$LOG_PATH/catlina.out 2>&1 &
tail -f $LOG_PATH/catlina.out
fi
}
#停止方法
stop() {
is_exist
if [ $? -eq "0" ]; then
kill -9 $pid
else
echo "${APP_NAME} is not running"
fi
}
#输出运行状态
status() {
is_exist
if [ $? -eq "0" ]; then
echo "${APP_NAME} is running. Pid is ${pid}"
else
echo "${APP_NAME} is not running."
fi
}
#重启
restart() {
stop
start
}
#根据输入参数,选择执行对应方法,不输入则执行使用说明
case "$1" in
"start")
start
;;
"stop")
stop
;;
"status")
status
;;
"restart")
restart
;;
*)
usage
;;
esac
相关推荐
SpringBoot windows启动脚本
windows下启动springboot的jar包, 自动启动springboot项目脚本文件
以下展示启动脚本示例,过程中遇到的问题,以及相关的解决办法。 1、启动脚本 #!/bin/sh export EUREKA=ruoyi-eureka-1.0.2-SNAPSHOT.jar export CONFIG=ruoyi-config-1.0.2-SNAPSHOT.jar export AUTH=ruoyi-auth-...
Springboot-服务-Windows 一键启动、停止脚本
spring boot windows 启动脚本
springboot项目linux系统下 通用 启动脚本 支持日志输出、远程调试开启 支持start、stop、restart命令 通用启动脚本,只需将服务名改成自己的服务名即可! 保证可用!
centos系统springboot启动、重启、停止shell脚本,centos系统springboot启动、重启、停止shell脚本
主要介绍了maven插件assembly使用及springboot启动脚本start.sh和停止脚本 stop.sh的相关资料,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下
springboot 执行脚本,启动,停止,重启等。
主要介绍了springboot启动脚本start.sh和停止脚本 stop.sh的详细教程,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下
springboot项目启动脚本,jar包项目万能启动脚本,只需要替换文件中注释的需要替换的地方 其他不需要改动,将脚本文件放到项目jar包相同目录下,再给脚本文件赋予权限:chmod +x 脚本文件名 之后直接:./脚本文件名...
SpringBoot Linux启动脚本
springboot项目启动脚本,在linux中修改jar包名称,赋予执行权限即可运行,使用./***.sh运行
springboot jar包启动脚本, 适用于快速启动,删除, 重启, 以及查看状态. 命令 sh jar-script.sh 可以查看启动方式
Springboot项目,快速启动脚本,可以结合需要自己看看
将app.sh和springboot的jar文件放到同一个文件夹中,使用sh app.sh start启动程序,sh app.sh stop停止程序,sh app.sh restart重启程序
springboot启动/停机脚本
修改jar包名称,修改脚本权限为777。 使用方法: ./server.sh start(stop/restart)