#!/bin/bash #--------------------------------------------------------- # kill tomcat 服务器 # # Filename: kill-tomcat.sh # Author: zll # Time: 2016/11/26 #-------------------------------------------------------- #查询tomcat进程信息,grep -v 去掉grep查询的进程信息及当前shell脚本 # $0 表示命令本身 tomcat=$(ps -ef|grep tomcat|grep -v grep|grep -v $0) # -z 判断字符串是否为空,空返回真 if [ -z "$tomcat" ] then echo "tomcat服务器未启动"; else echo "准备kill $tomcat..."; tomcat_pid=$(echo $tomcat|cut -d ' ' -f 2); kill -9 $tomcat_pid echo "kill $tomcat_pid 成功"; fi echo "结束";