码迷,mamicode.com
首页 > 系统相关 > 详细

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

时间:2019-01-20 11:55:04      阅读:176      评论:0      收藏:0      [点我收藏+]

标签:kill   ash   star   ini   finish   print   ids   art   code   

 

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"

 

 

 

.

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

标签:kill   ash   star   ini   finish   print   ids   art   code   

原文地址:https://www.cnblogs.com/jonban/p/10294143.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!