Jbossstop script problems

Source: Internet
Author: User
Jbossstop script-general Linux technology-Linux technology and application information. For details, see the following section. [I = s] This post was last edited by lraxy at, January 28 ,.

Create a control. sh file by yourself. The following is the content in the file. It is okay to start the file and there is an error when it is stopped. See the bottom.

System Environment Red Hat Enterprise Linux Server release 5.3

#! /Bin/sh
#
# $ Id: jboss_init_redhat.sh 60992 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 'jbos' 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




Run
The first line of the stop_broker () method
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 }''
When the system prompts Warning: bad syntax, perhaps a bogu '-'? See/usr/share/doc/procps-3.2.7/FAQ

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.