例:tomcat路径及名称为/data/apache-tomcat-7.0.67/
vim /data/apache-tomcat-7.0.67/bin/catalina.sh
找到org.apache.catalina.startup.Bootstrap "$@" stop这行,然后在这行下面加上
if [ $? -eq 0 ];then kill -9 `ps -ef |grep tomcat |awk '/.*/data/apache-tomcat-7.0.67/.*/{print $2}'` fi
或
if [ $? -eq 0 ];then ps -ef | grep -v "grep --color=auto" | grep "/data/apache-tomcat-7.0.67" |awk '{print "kill -9 "$2}' |bash fi
暴力但实用