linux启动脚本springboot,Linux 启动停止SpringBoot jar 程序部署Shell 脚本的方法
废话不多说了,先给大家上代码,具体代码如下所示:
#!/bin/bash
cd `dirname $0`
cur_shell_dir=`pwd`
cur_shell_name=`basename ${bash_source}`
#修改这里jar包名即可
jar_name="xxxxxxxxxxxx.jar"
jar_path=$cur_shell_dir/$jar_name
#java_mem_opts=" -server -xms1024m -xmx1024m -xx:permsize=128m"
java_mem_opts=""
#spring_profiles_activ="-dspring.profiles.active=eureka2"
spring_profiles_activ=""
log_dir=$cur_shell_dir/logs
log_path=$log_dir/${jar_name}.log
echo_help()
{
echo -e "syntax: sh $cur_shell_name start|stop"
}
if [ -z $1 ];then
echo_help
exit 1
fi
if [ ! -d "$log_dir" ];then
mkdir "$log_dir"
fi
if [ ! -f "$log_path" ];then
touch "$log_dir"
fi
if [ "$1" == "start" ];then
# check server
pids=`ps --no-heading -c java -f --width 1000 | grep $jar_name | awk '{print $2}'`
if [ -n "$pids" ]; then
echo -e "error: the $jar_name already started and the pid is ${pids}."
exit 1
fi
echo "starting the $jar_name..."
# start
nohup java $java_mem_opts -jar $spring_profiles_activ $jar_path >> $log_path 2>&1 &
count=0
while [ $count -lt 1 ]; do
sleep 1
count=`ps --no-heading -c java -f --width 1000 | grep "$jar_name" | awk '{print $2}' | wc -l`
if [ $count -gt 0 ]; then
break
fi
done
pids=`ps --no-heading -c java -f --width 1000 | grep "$jar_name" | awk '{print $2}'`
echo "${jar_name} started and the pid is ${pids}."
echo "you can check the log file in ${log_path} for details."
elif [ "$1" == "stop" ];then
pids=`ps --no-heading -c java -f --width 1000 | grep $jar_name | awk '{print $2}'`
if [ -z "$pids" ]; then
echo "error:the $jar_name does not started!"
exit 1
fi
echo -e "stopping the $jar_name..."
for pid in $pids; do
kill $pid > /dev/null 2>&1
done
count=0
while [ $count -lt 1 ]; do
sleep 1
count=1
for pid in $pids ; do
pid_exist=`ps --no-heading -p $pid`
if [ -n "$pid_exist" ]; then
count=0
break
fi
done
done
echo -e "${jar_name} stopped and the pid is ${pids}."
else
echo_help
exit 1
fi
以上代码只需修改jar包名即可使用
启动jar包:
./xxxx.sh start
停止 jar包
./xxxx.sh stop
总结
以上所述是小编给大家介绍的linux 启动停止springboot jar 程序部署shell 脚本的方法,希望对大家有所帮助
linux启动脚本springboot,Linux 启动停止SpringBoot jar 程序部署Shell 脚本的方法相关推荐
- linux停止jar程序,Linux 启动停止SpringBoot jar 程序部署Shell 脚本的方法
废话不多说了,先给大家上代码,具体代码如下所示: #!/bin/bash cd `dirname $0` CUR_SHELL_DIR=`pwd` CUR_SHELL_NAME=`basename ${ ...
- jar包部署shell脚本编写,在服务器上部署jar包,在Linux服务器上部署服务,设置编码格式,设置内存管理
准备步骤: 1.安装java环境,知道java安装目录 2.将jar包拖放或发送至服务器中(目录自定义) 一.编写shell脚本,将以下代码放在shell脚本中,将shell脚本放在jar包同级目录下 ...
- Linux系统防CC攻击自动拉黑IP增强版Shell脚本
Linux系统防CC攻击自动拉黑IP增强版Shell脚本 文章目录 一.Shell代码 二.执行脚本 三.效果测试 四.附加说明 前天没事写了一个防CC攻击的Shell脚本,没想到这么快就要用上了,原 ...
- linux下bash脚本常用的十个技巧:显示执行脚本花费的时间,在脚本退出时杀死后台运行的程序,在脚本退出时跳出循环,读取命令行参数来决定循环次数
文章目录 1.显示执行脚本花费的时间 2.在脚本退出时杀死后台运行的程序 3.在脚本退出时跳出循环 4.读取命令行参数来决定循环次数 1.显示执行脚本花费的时间 网址:bash - How to ge ...
- Linux系统防CC攻击自动拉黑IP增强版(Shell脚本)
这篇文章主要介绍了Linux系统防CC攻击自动拉黑IP增强版(Shell脚本),需要的朋友可以参考下 前天没事写了一个防CC攻击的Shell脚本,没想到这么快就要用上了,原因是因为360网站卫士的缓存 ...
- shell安装mysql5.7_一键部署----shell脚本安装MySQL5.7
运维开发网 https://www.qedev.com 2020-11-09 12:30 出处:51CTO作者:wx5ddda4c97f426 一键部署----shell脚本安装MySQL5.7#/b ...
- Linux配置脚本导出运行,linux服务器部署jar包以及shell脚本的书写
背景:记录在linux环境下部署jar程序的过程 1 部署过程记录 1.1 程序结构 这里的main函数就在DemRest2.java 文件中. 为了部署方便,要做到以下两点: 1 在导出的jar包中 ...
- linux shell命令分布执行,Linux学习笔记:bash特性之多命令执行,shell脚本
今天我们学习了bash特性多命令执行包括各个命令之间的逻辑关系.其中包含"与""或""非"命令的执行.下面即为我们所学习的这些逻辑命令关系之 ...
- 【Linux】30.ssh不用手动输入密码登录终端sshpass 和 shell脚本后跟参数自动匹配case的用法
ssh不用手动输入密码登录终端sshpass 和 case的组合用法 1.sshpass 的用法 在第一次手动输入密码ssh mdc@172.16.34.17 登陆上终端后,可以把下面两条语句做成sh ...
最新文章
- vim配置python开发环境_VIM插件管理及python开发环境配置
- SharePoint【Query Options系列】-- Query Options的一些用法 01. 展开用户列信息
- document.compatMode属性
- android ptrace注入
- 第五届新疆ACM H-虚无的后缀
- DOMContentLoaded与interactive
- 论文致谢走红后,中科院博士回信了!
- 字串变换(洛谷-P1032)
- python实现指纹识别毕业论文_指纹识别算法实现本科毕业论文
- STM32压力传感器信号采集- C#上位机 波形显示
- 忆亚强建筑预算软件的2001年半年时光
- 如何做好软件可靠性测试?
- 在scrapy中params无处安放???
- Obi Cloth 仿真布 学习
- 上次送女神死亡芭比粉口红后,我痛定思痛
- 论文阅读笔记--Monocular Human Pose Estimation: A Survey of Deep Learning-based Methods 人体姿态估计综述
- 手机(wap)网页底部固定悬浮广告带轮播特效代码
- 包子笔记 - 摆脱穷人思维
- Go 开源说第十五期预告: Erda ——新一代企业级云原生 PaaS 平台
- 【I.MX6ULL学习笔记·五】 点灯
热门文章
- myFAX网络传真服务器与同类产品比较的优势
- PHP获取上月月初和月末时间,获取指定时间的月初以及月末时间
- 【2019.08.20】 python 下载wallhaven壁纸原图, 分别使用同步、异步方式(aiohttp_requests,aiofiles),对比下载速度
- 黑客与画家 Hackers and Painters: Big Ideas from the Computer Age
- 鸽兔同场+求解方程+数组距离
- python nltk 10 分析句子的意思
- Avalon-MM接口地址对齐方式浅析
- Linux的help命令的使用详解
- C++20三路比较运算符
- FEKO学习:1.前处理模块——CADFEKO、2.建模时直接移动坐标系使用相对坐标系