> CentOS > CentOS教程 >

CentOS杀死指定Tomcat服务的PID进程并重启Tomcat服务


#!/bin/sh
#
# -----------------------------------------------------------------------------
# Description: Start Script for the CATALINA Server
# Author: Aaric
# Date: 2014-03-04
# -----------------------------------------------------------------------------
DATE=`date +%F`
TOMCAT_RELATIVE_PATH=tomcat7_test

TOMCAT_PID=`ps -ef | grep $TOMCAT_RELATIVE_PATH | grep -v grep| awk '{print $2}'`

ulimit -HSn 65535

if [ -n "$TOMCAT_PID" ] ; then
  echo "=====Kill The Tomcat PID($TOMCAT_PID) By Force====="
  kill -9 $TOMCAT_PID
  sleep 3
fi

echo "=====Start The Tomcat Service====="
/usr/local/www/$TOMCAT_RELATIVE_PATH/bin/startup.sh

sleep 3

echo "=====Show The Tomcat Log($DATE)====="
tail -f /usr/local/www/$TOMCAT_RELATIVE_PATH/logs/catalina.out

(责任编辑:IT)