#!/bin/bash
need_stop=`ps -ef|grep java|grep -viE "grep root"|awk '{print $2}'`
pwdx $need_stop>stop_all_process.txt
txtline=`cat stop_all_process.txt|wc -l`
sed 's/[[:space:]]//g' stop_all_process.txt>process_file.txt
rm -f stop_all_process.txt
for ((j=1;j<=$txtline;j++));
do
dir=`sed -n "${j}p" process_file.txt|awk -F ':' '{print $NF)'`
echo "dir:"$dir
if [ -d $dir ];then
domain=`sed -n "${j}p" process_file.txt|awk -F '/' '{print $NF}'`
pid=`cat process_file.txt|grep -i $domain|cut -d -f1`
echo "Kill the Weblogic $domain service [$pid]"
kill -9 $pid
echo "The $domain service has been stoped!!"
else
echo "$pid No such process!!"
fi
done
注:上述代码为个人所有,转载需要注明来源。个人邮箱:shiyan31214@163.com;微信:shiyan31214
need_stop=`ps -ef|grep java|grep -viE "grep root"|awk '{print $2}'`
pwdx $need_stop>stop_all_process.txt
txtline=`cat stop_all_process.txt|wc -l`
sed 's/[[:space:]]//g' stop_all_process.txt>process_file.txt
rm -f stop_all_process.txt
for ((j=1;j<=$txtline;j++));
do
dir=`sed -n "${j}p" process_file.txt|awk -F ':' '{print $NF)'`
echo "dir:"$dir
if [ -d $dir ];then
domain=`sed -n "${j}p" process_file.txt|awk -F '/' '{print $NF}'`
pid=`cat process_file.txt|grep -i $domain|cut -d -f1`
echo "Kill the Weblogic $domain service [$pid]"
kill -9 $pid
echo "The $domain service has been stoped!!"
else
echo "$pid No such process!!"
fi
done
注:上述代码为个人所有,转载需要注明来源。个人邮箱:shiyan31214@163.com;微信:shiyan31214