restart。sh

上一篇 / 下一篇  2014-03-27 16:31:31 / 个人分类:linux

#!/bin/bash
#===============================
#echo cmd   : kill_process
#echo author: walter.chen
#echo email : walt_chen@163.com
#echo ver   : 2011/06/02 11:33
#echo ===============================
NAME=$3
echo $NAME
echo $2
echo $3
ID=`ps -ef | grep "$NAME" | grep -v "$0" | grep -v "grep" | awk '{print $2}'`
IDNAME=`ps -ef | grep "$NAME" | grep -v "$0" | grep -v "grep" | awk '{print $8}'`
echo process ID   list: $ID
#echo process NAME list: $IDNAME
echo "--start kill-------------"
for id in $ID
do
kill -9 $id
echo "killed $id $NAME"
done
echo "--kill_process finished!-"

echo "--restart $3--"
#export LANG=zh_CN.GBK
cd $2
echo `pwd`
nohup java -Dfile.encoding=GBK -jar $3 &> /dev/null &

sleep 5s

NEW_ID=`ps -ef | grep "$NAME" | grep -v "$0" | grep -v "grep" | awk '{print $2}'`

if [ -z $NEW_ID ]; then
echo "restart failed!"
exit 1;
fi


echo "--restart over! new id:$NEW_ID"

TAG:

 

评分:0

我来说两句

Open Toolbar