linux jboss 脚本启动脚本,jboss stop 脚本问题

jboss stop 脚本问题

发布时间:2011-01-28 13:44:35来源:红联作者:lraxy

[i=s] 本帖最后由 lraxy 于 2011-1-28 13:48 编辑 [/i]

自己建立一个control.sh文件,下面是文件里的内容,启动没问题,停止的时候有错误,见最下面

系统环境 Red Hat Enterprise Linux Server release 5.3

#!/bin/sh

#

# $Id: jboss_init_redhat.sh 60992 2007-02-28 11:33:27Z dimitris@jboss.org $

#

# JBoss Control Script

#

# To use this script run it as root - it will switch to the specified user

#

# Here is a little (and extremely primitive) startup/shutdown script

# for RedHat systems. It assumes that JBoss lives in /usr/local/jboss,

# it's run by user 'jboss' and JDK binaries are in /usr/local/jdk/bin.

# All this can be changed in the script itself.

#

# Either modify this script for your requirements or just ensure that

# the following variables are set correctly before calling the script.

JBOSS_HOME=/usr/server/jboss-4.2.2.GA

JAVA_HOME=/usr/java/jdk1.5.0_17

USER_NAME=`/usr/bin/id -un`

LOG_HOME=$JBOSS_HOME/logs

LOG_FILE=$LOG_HOME/run

rval=0

## kill the child process

kill_child()

{

pid_list=`ps -o user=$USER_NAME -o pid -o ppid -o args -eaf | grep "$2" | grep -v "grep" | /usr/bin/awk '{if($3==parent) print $2}' parent=$2`

# kill parent process first

# after kill the parent, the child will be hung under "1" main process

kill $1 $2 >> $LOG_FILE-`date '+%y-%m-%d'`.log 2>&1

# kill child following

for i in $pid_list

do

/bin/echo "\t kill child process id: $i ... \c"

kill $1 $i >> $LOG_FILE-`date '+%y-%m-%d'`.log 2>&1

ret=$?

if [ $ret -ne 0 ]; then

/bin/echo "failed."

else

/bin/echo "done."

fi

done

}

## function of stop broker

stop_broker()

{

pid_list=`ps -o user=$USER_NAME -o pid -o ppid -o args -eaf | grep $USER_NAME | grep "$1" | grep -v grep | /usr/bin/awk '{print $2}'`

for i in $pid_list

do

/bin/echo "Parent process id: $i"

kill_child -9 $i "$1"

/bin/echo "done."

/bin/echo "jBoss Server stopped!" >> $LOG_FILE-`date '+%y-%m-%d'`.log

done

}

## function of start broker

start_broker()

{

# cur_list=`/usr/bin/ps -o user=$USER_NAME -o pid -o ppid -o args -eaf | /usr/bin/grep $JBOSS_HOME/bin/runjboss | /usr/bin/grep -v "grep"`

# if [ "$cur_list" != "" ]; then

# /bin/echo "There has already a proccess started!"

# exit 0

# fi

# rm -rf $JBOSS_HOME/tomcat-4.1.x/work/MainEngine >> /dev/null 2>&1

rm -rf $JBOSS_HOME/server/all/tmp/deploy/server >> /dev/null 2>&1

nohup $JBOSS_HOME/bin/runjboss.sh >> $LOG_FILE-`date '+%y-%m-%d'`.log 2>&1 &

ret=$?

if [ $ret -ne 0 ]; then

/bin/echo "failed!"

/bin/echo "EXIT CODE: $ret"

rval=1

else

/bin/echo "successfully!"

fi

}

## Main process

case "$1" in

'start')

/bin/echo "Starting jBoss Server with Catalina ... \c"

start_broker

;;

'stop')

/bin/echo "Stopping jBoss Server ... "

stop_broker $JBOSS_HOME/bin/runjboss

#$JBOSS_HOME/bin/shutdown.sh -S

#rm -rf $JBOSS_HOME/tomcat-4.1.x/work/MainEngine >> /dev/null 2>&1

#rm -rf $JBOSS_HOME/server/all/tmp/deploy/server >> /dev/null 2>&1

;;

'restart')

/bin/echo "Stopping jBoss Server ... "

stop_broker $JBOSS_HOME/bin/runjboss

#$JBOSS_HOME/bin/shutdown.sh -S

#rm -rf $JBOSS_HOME/tomcat-4.1.x/work/MainEngine >> /dev/null 2>&1

#rm -rf $JBOSS_HOME/server/all/tmp/deploy/server >> /dev/null 2>&1

/bin/echo "Starting jBoss Server with Catalina ... \c"

start_broker

;;

*)

/bin/echo "usage: $0 {start|stop|restart}"

;;

esac

exit $rval

执行到

stop_broker()方法的第一行

pid_list=`ps -o user=$USER_NAME -o pid -o ppid -o args -eaf | grep $USER_NAME | grep "$1" | grep -v grep | /usr/bin/awk '{print $2}'`

的时候提示Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.7/FAQ

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值