Shell脚本查找tomcat进程号并关闭 同时删除项目解压文件夹

脚本演示如何通过用户确认执行杀进程(kill-9)和删除cqsg目录的操作,适用于快速维护场景。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

#!/bin/bash
pid=$(ps -ef | grep tomcat-8.5.42 | grep -v grep | awk '{print $2}')
echo "pid=:${pid}"
read -p "confirm shutdown tomcat and remove cqsg directory (y/n): " confirmed
if [  "${confirmed}" == "y" ] ||  [ "${confirmed}" == "Y" ];then
	kill -9 ${pid}
	rm -rf /app/apache-tomcat-8.5.42/webapps/cqsg/
	echo "shutdown tomcat and remove cqsg directory Success... "
	exit 0
elif [  "${confirmed}" == "n" ] ||  [ "${confirmed}" == "N" ];then
	echo "cancel shutdown tomcat and remove cqsg directory... "
	exit 0
fi

 

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值