#!/bin/bashecho -e "\n\n\n"#force kill flag,if equal [f] to force kill allflag="HelloShell"if test $# -gt 0then flag=$1fipids=`ps -ef|grep tomcat | grep -v "grep" | awk '{print $2}'`#pids=`ps -ef|grep -w tomcat | grep -v "grep" | awk '{print $2}'`count=0pid_num=0for pid in ${pids}do pid_num=${pid} count=`expr ${count} + 1`doneif test $[count] -gt 1then if test $flag = "f" then for pid in ${pids} do echo "kill " ${pid} kill -9 ${pid} done echo "Force kill more progress success!" else echo "Exist more progress is running, Input param [f] to force kill." fielse if test $[count] -eq 1 then kill -9 ${pid_num} echo "Kill " ${pid_num} " Success!" else echo "Clear!" fifi# startbash /root/soft/apache-tomcat-7.0.90/bin/startup.shecho -e "\n\n\n"