#!/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
本文提供了一个简单的Shell脚本,用于检查并重启运行在8080端口上的Tomcat服务器。该脚本首先通过lsof命令获取进程ID,然后使用条件语句判断是否需要启动Tomcat。
348

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



