---
title: "tomcat关闭脚本"
author: "cping"
date: "2015-01-14T15:25:42Z"
tags: []
categories: ["Web前端"]
slug: "tomcat"
draft: false
lastmod: "2015-01-14T15:49:09Z"
id: 2175852
url: "https://cping.iteye.com/blog/2175852"
---

没写过shell脚本，今天尝试写了个关闭tomcat的脚本，保存下。

```shell

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


```