shell停止/启动/重启tomcat

Linux 启动、停止、重启tomcat工具(Shell脚本)

 

 

1.   启动

复制代码
#!/bin/bash

pids=`ps -ef | grep java | grep -w tomcat | awk '{print $2}'`
#pids=`ps -ef | grep -w tomcat | grep -v "grep" | awk '{print $2}'`

if test -z $pids
then
    bash /root/soft/tomcat/bin/startup.sh
    echo -e "Start Finished!\n"
else
   echo -e "tomcat has already started!\n"
fi
复制代码

 

 

2.  停止

复制代码
#!/bin/bash

pids=`ps -ef | grep java | grep -w tomcat | awk '{print $2}'`
#pids=`ps -ef | grep -w tomcat | grep -v "grep" | awk '{print $2}'`

for pid in ${pids}
do
    kill -9 ${pid}
done

echo -e "Stop Finished!\n"
复制代码

 

 

3.  重启

复制代码
#!/bin/bash

pids=`ps -ef | grep java | grep -w tomcat | awk '{print $2}'`
#pids=`ps -ef | grep -w tomcat | grep -v "grep" | awk '{print $2}'`

for pid in ${pids}
do
    kill -9 ${pid}
done

# start
bash /root/soft/tomcat/bin/startup.sh

echo -e "Restart Finished!\n"
复制代码

 

posted @ 2020-01-03 17:25  wang9264  阅读(461)  评论(0编辑  收藏  举报