Recycle Jboss server script | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Recycle Jboss server script

Shell Programming and Scripting


Tags
jboss, korn shell, restart

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 04-06-2012
Blogger11 Blogger11 is offline
Registered User
 
Join Date: Jan 2011
Last Activity: 13 June 2012, 2:23 PM EDT
Posts: 11
Thanks: 2
Thanked 0 Times in 0 Posts
Recycle Jboss server script

Hello, I need help writing a script to restart our Jboss server when it crashes. I am not very good with scripting but here is the basics.

1) I'm hoping to use KornShell
2) The command to stop the Jboss is "/var/opt/HP/ALM/jboss/bin/run.sh stop"
3) I want to verify the jboss is stopped before attempting to restart, not sure how to do this at all
4) Start the jboss "/var/opt/HP/ALM/jboss/bin/run.sh start"

Should be very simple but I just am not sure where to start, how to get that stop/start command to be input into the string. Can anyone help?
Sponsored Links
    #2  
Old 04-08-2012
kevintse's Avatar
kevintse kevintse is offline
Registered User
 
Join Date: May 2010
Last Activity: 24 May 2013, 10:11 PM EDT
Location: GuangZhou, China
Posts: 248
Thanks: 8
Thanked 28 Times in 27 Posts
For detecting the server crash, you need some info from which to tell that, maybe from a log file generated by the JBoss server, you can setup a cron job to grep the log file regularly. After that, you can try to stop the JBoss server with its stop script, wait some time and then use ps -ef | grep my_jboss_server to check whether it's stopped, if it is not, you may want to directly kill the process(Caution, killing a JBoss process directly may cause some damage to your data, some lifecycle code may not be executed).

The following script is for reference:

Code:
crash_msg=$(grep -o "AN_ERROR_MSG_MEANS_CRASH" jboss_log_file)
if [[ $crash_msg != "" ]]; then
    /var/opt/HP/ALM/jboss/bin/run.sh stop
    sleep 5
    ps -ef | awk '/my_jboss_server/{print $2}' | xargs kill -9 # change my_jboss_server to a relevant string in your environment
    /var/opt/HP/ALM/jboss/bin/run.sh start
fi

Note: Try these commands at home before you use them on production environment.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Single Startup script for Apache/jboss saurau Shell Programming and Scripting 6 03-27-2011 05:42 PM
Script to monitor JBoss web server nsachin Shell Programming and Scripting 2 11-13-2009 12:53 PM
Recycle Bin Script chueu Shell Programming and Scripting 2 05-21-2009 12:21 AM
JBoss Application Server 5 CR1 available Linux Bot Red Hat 0 09-11-2008 10:07 AM
Recycle Bin Script raidersboi UNIX for Dummies Questions & Answers 6 06-04-2005 11:32 PM



All times are GMT -4. The time now is 05:48 AM.