没写过shell脚本,今天尝试写了个关闭tomcat的脚本,保存下。
echo "stop tomcat"
tomcatId=$(ps -ef |grep tomcat |grep /home/apache-tomcat-7.0.57 |grep -v 'grep'|awk '{print $2}')
echo "tomcat id="$tomcatId
if test -z "$tomcatId"
then
echo "tomcat does not exist!"
else
kill -9 $tomcatId
fi