Jboss重启、关闭的shell脚本
上一篇 /
下一篇 2013-02-21 14:05:36
/ 个人分类:测试技术
#!/bin/sh
export JAVA_HOME="/usr/java/jdk1.6.0_25"
export PATH="/usr/java/jdk1.6.0_25/bin:$PATH"
export CLASSPATH=".:/usr/java/jdk1.6.0_25/lib:/usr/java/jdk1.6.0_25/jre/lib"
#start commond
MSTART="nohup /home/webadmin/jboss-as-7.0.1.Final/bin/standalone.sh &"
USERNAME="webadmin"
#stop jboss
if [ "$1" = "stop" ]
then
#kill all Pid
pidlist=`ps -ef | grep jboss |grep $USERNAME | grep -v "grep"|awk '{print $2}'`
if [ "$pidlist" = "" ]
then
echo "No Service Running!"
else
for pid in ${pidlist}
{
kill -9 $pid
}
echo "Service Stop Success!"
fi
fi
#start jboss
if [ "$1" = "start" ]
then
pidlist=`ps -ef | grep jboss | grep $USERNAME | grep -v "grep"|awk '{print $2}'`
echo "ps -ef | grep jboss | grep $USERNAME | grep -v "grep"|awk '{print $2}'"
if [ "$pidlist" = "" ]
then
nohup $MSTART > /dev/null 2>&1 &
pidlist=`ps -ef | grep jboss |grep $USERNAME | grep -v "grep"|awk '{print $2}'`
if [ "$pidlist" = "" ]
then
echo "Service Start Failed!"
else
echo "Service Start Success!"
fi
else
echo "Service Exists!"
fi
fi
#restart jboss
if [ "$1" = "restart" ]
then
#kill all Pid
pidlist=`ps -ef | grep jboss |grep $USERNAME | grep -v "grep"|awk '{print $2}'`
if [ "$pidlist" != "" ]
then
for pid in ${pidlist}
{
kill -9 $pid
}
echo "Service Stop Success!"
fi
#start jboss
nohup $MSTART > /dev/null 2>&1 &
pidlist=`ps -ef | grep jboss | grep $USERNAME | grep -v "grep"|awk '{print $2}'`
if [ "$pidlist" = "" ]
then
echo "Service Start Failed!"
else
echo "Service Start Success!"
fi
fi
#check is running
if [ "$1" = "check" ]
then
pidlist=`ps -ef | grep jboss | grep $USERNAME | grep -v "grep"|awk '{print $2}'`
if [ "$pidlist" = "" ]
then
echo "Service Not Exists!"
else
echo "Service Exists! pid is: "
for pid in ${pidlist}
{
echo $pid
}
fi
fi
if [ -z "$1" ]
then
echo "Parm must be: [start|stop|restart|check]"
fi
收藏
举报
TAG:
Jboss
jboss
JBoss
shell
Shell