In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the relevant knowledge of "how to start and stop SpringBoot jar programs in Linux". The editor shows you the operation process through actual cases. The operation method is simple, fast and practical. I hope this article "how to start and stop SpringBoot jar programs in Linux" can help you solve the problem.
The specific code is as follows:
#! / bin/bashcd `cur $0`cur _ shell_dir= `pwd`cur _ shell_name= `basename ${bash_source} `# modify the jar package name here to 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/logslog_path=$log_dir/$ {jar_name}. Logecho_help () {echo-e "syntax: sh $cur_shell_name start | stop"} if [- z $1] Then echo_help exit 1fiif [!-d "$log_dir"]; then mkdir "$log_dir" fiif [!-f "$log_path"]; then touch "$log_dir" fiif ["$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 fiecho "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 fiecho-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 1fi
The above code can be used simply by changing the jar package name
Start the jar package:
. / xxxx.sh start
Stop the jar package
. / xxxx.sh stop
This is the end of the introduction to "how Linux starts and stops SpringBoot jar programs". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.