当前位置:网站首页>Start jar package shell script
Start jar package shell script
2022-07-22 11:17:00 【@NYL】
jar_name=xxx.jar
jar_path=/xxx/xxxx
log_path=/xxx/logs/`date +%y-%m-%d`_out.log
# Point to custom jdk
#export JAVA_HOME=/xxx/xxx/jdk1.8.0_131
#export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
#export PATH=$JAVA_HOME/bin:$PATH
stop() {
echo ""
pid=$(ps -ef | grep $jar_name | grep -v grep | awk '{
print $2}')
if [ -z $pid ]; then # -z Yes judge whether it is empty
echo "${jar_name} Not running !"
else
echo " Ready to shut down the process $pid"
kill -9 $pid
sleep 0.5
echo "${jar_name} closed !"
fi
echo ""
}
start() {
echo ""
pid=$(ps -ef | grep $jar_name | grep -v grep | awk '{
print $2}')
if [ -z $pid ]; then
cd $jar_path # Go here jar The package directory executes the command , To use jar_path Under the config file , Looks like java The program can only recognize the configuration under the current command directory , Otherwise, it is to use the entered Jar Package configuration file .
nohup java -jar $jar_name >$log_path 2>&1 &
pid=$(ps -ef | grep $jar_name | grep -v grep | awk '{
print $2}')
echo " application ${jar_name} Successful launch ,pid=${pid}"
# tail -f $log_path
else
echo " application ${jar_name} Running ,pid = ${pid}"
fi
echo ""
}
status() {
echo ""
pid=$(ps -ef | grep $jar_name | grep -v grep | awk '{
print $2}')
if [ -z $pid ]; then
echo " application ${jar_name} Not running "
else
echo " application ${jar_name} Running ,pid = ${pid}"
fi
echo ""
}
restart() {
stop
sleep 2
echo " Stop completing , Ready to start jar package "
start
}
action() {
echo " Please enter a number to select the action to perform :1= start-up ,2= restart ,3= stop it ,4= View running status ,5= sign out "
echo ' The number you enter is :'
read a
case $a in
"1")
start
;;
"2")
restart
;;
"3")
stop
;;
"4")
status
;;
"5")
exit 1
;;
*)
echo " Input error , Please re-enter "
action
;;
esac
}
action
边栏推荐
- systemd 管理 blackbox-exporter
- 【string类】
- [unity3d] blood bar (HP)
- 同花顺上面开户安全吗 reits基金怎么购买
- 美参议院初步通过520亿美元「芯片法案」,她竟乘机「投资炒股」!
- 力扣------统计有序矩阵中的负数
- systemd 管理 redis-exporter linux
- [makefile] error: undefined reference to symbol 'pthread_ spin_ [email protected]@GLIBC_ 2.2.5‘
- Is it safe to open an account on tonghuashun online? How to buy national debt reverse repurchase
- SYSTEMd manages redis exporter Linux
猜你喜欢
AcWing 1124. Solution to the problem of repairing fences on horseback (Euler circuit)
How can I sync previous online notes after OneNote is reinstalled or upgraded?
B2B企业数字化转型,CIO如何避免踩坑
C. Doremy‘s IQ(贪心)
The air conditioner in no man's land has poor refrigeration
Example interview - Zeng yuluo: gain experience from lectures
systemd 管理 blackbox-exporter
OSPF综合实验
什么是因果深度学习?DeepMind最新ICML2022《因果性与深度学习:协同、挑战和未来》教程
ADVANCE.AI:目前进入拉美地区的中国企业还较少,值得探索
随机推荐
sql语句,分组后,组内根据datetime字段排序,保留日期最新的一条组内记录,删除其他项。(用于组内重复数据的剔除)
[public class preview]: cloud video conference system privatization practice
Is the flush platform safe? Huatai Securities Account Opening app
云呐-咸宁通信机房动环监控系统,电信动环监控系统
[解决]vscode代码没有输入完成就自动换行bug
Delivery practice of private PAAS platform based on cloud native
学生管理系统(文件版)
软件测试工程师 | 不拼学历,还能进大厂吗?
双指针(一)
网络安全竞赛C模块批量拿值脚本
B2B企业数字化转型,CIO如何避免踩坑
Chapter1 Beginning Bash
What is a video content recommendation engine?
NASA「史上最强超算」投入使用,碾压老超算霸主Pleiades
TCP 通信流程详解(附有案例代码)
【红队】ATT&CK - Active Scanning(主动扫描)
unity2D 箭头动画
推荐必读:测试人员如何快速熟悉新业务?
【学习笔记】带你从0开始学习 01Trie
Download datasets using kaggle's API