#!/bin/bash
pid=`lsof -i:8080 |sed -n 2p | awk '{print $2}'`
echo $pid
if [ "-$pid" = "-" ];then
echo "start to restart tomcat at port 8080"
su - huawei -c 'sh /home/huawei/tomcat/bin/startup.sh'
# cd /home/huawei/tomcat/bin
#sh startup.sh
fi
本文介绍了一段使用bash脚本监控Tomcat运行状态,并在端口8080出现空闲时自动重启Tomcat实例的实现方法。通过lsof命令检查端口占用情况,结合条件判断实现自动化管理。
348

被折叠的 条评论
为什么被折叠?



