目录
将以下脚本保存为 killtomcat.sh,并移动到${tomcat_home}/bin 目录下,并设置执行权限。
执行后会杀死改目录下的tomcat进程
#!/bin/bash
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
TARGET="$(readlink "$SOURCE")"
if [[ $TARGET == /* ]]; then
echo "SOURCE '$SOURCE' is an absolute symlink to '$TARGET'"
SOURCE="$TARGET"
else
DIR="$( dirname "$SOURCE" )"
echo "SOURCE '$SOURCE' is a relative symlink to '$TARGET' (relative to '$DIR')"
SOURCE="$DIR/$TARGET" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
fi
done
#echo "SOURCE is '$SOURCE'"
RDIR="$( dirname "$SOURCE" )"
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
if [ "$DIR" != "$RDIR" ]; then
echo "DIR '$RDIR' resolves to '$DIR'"
fi
echo "DIR is '$DIR'"
PDIR="$( dirname "$DIR" )/endorsed"
PID="$( ps -ef | grep $PDIR | grep -v grep | awk '{print $2}' | sed -e "s/^//g" )"
echo "PID is $PID"
echo "$( ps -ef | grep $PDIR )"
for key in ${PID[*]}
do
echo "kill $key"
kill -9 $key
done
echo "kill done"
#kill -9 $PID
#ps -ef | grep $PDIR | grep -v grep | awk '{print $2}' | sed -e "s/^/kill -9 /g" | sh