Shell批量启动、关闭tomcat
批量启动tomcat脚本,配置NUM可控制启动数量
1 #!/bin/bash
2
3 #identifier
4 CLUSTER_HOME=/opt/cluster-tomcat
5 TNAME=tomcat-8.5.32-0
6 TPORT=808
7 NUM=2
8 MUTE=" >> /dev/null 2>&1"
9 COPYRIGHT="~~~~~~~~~~~Powered by GuangSoft"
10
11 #script
12 for i in `seq 1 $NUM`;
13 do
14 netstat -ano | grep $TPORT${i} | grep -v grep >> /dev/null 2>&1
15 if [ $? -ne 0 ]
16 then
17 echo -e "\nstarting ${TNAME}${i}. $COPYRIGHT\n"
18 STARTSCRIPT="$CLUSTER_HOME/$TNAME${i}/bin/startup.sh $MUTE"
19 eval $STARTSCRIPT
20 netstat -ano | grep $TPORT${i} | grep -v grep >> /dev/null 2>&1
21 if [ $? -ne 0 ]
22 then
23 echo -e "\n${TNAME}${i} has started successful! $COPYRIGHT\n"
24 else
25 echo -e "\n${TNAME}${i} start failed! $COPYRIGHT\n"
26 fi
27 else
28 echo -e "\n${TNAME}${i} is already started! $COPYRIGHT\n"
29 fi
30 done
批量关闭tomcat脚本,配置NUM可控制关闭数量
1 #!/bin/bash
2
3 #identifier
4 CLUSTER_HOME=/opt/cluster-tomcat
5 TNAME=tomcat-8.5.32-0
6 TPORT=808
7 NUM=3
8 MUTE=" >> /dev/null 2>&1"
9 COPYRIGHT="~~~~~~~~~~~Powered by GuangSoft"
10
11 #script
12 for i in `seq 1 $NUM`;
13 do
14 netstat -ano | grep $TPORT${i} | grep -v grep >> /dev/null 2>&1
15 if [ $? -ne 0 ]
16 then
17 echo -e "\n${TNAME}${i} is already stopped! $COPYRIGHT\n"
18 else
19 echo -e "\nstopping ${TNAME}${i}. $COPYRIGHT\n"
20 STOPSCRIPT="$CLUSTER_HOME/$TNAME${i}/bin/shutdown.sh $MUTE"
21 eval $STOPSCRIPT
22 netstat -ano | grep $TPORT${i} | grep -v grep >> /dev/null 2>&1
23 if [ $? -ne 0 ]
24 then
25 echo -e "\n${TNAME}${i} stop failed! $COPYRIGHT\n"
26 else
27 echo -e "\n${TNAME}${i} has stopped successful! $COPYRIGHT\n"
28 fi
29 fi
30 done
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异
· 三行代码完成国际化适配,妙~啊~
2017-02-14 MyEclipse激活失败