Unix/Linux Go Back    

Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Recycle Jboss server script

Shell Programming and Scripting

jboss, korn shell, restart

Thread Tools Search this Thread Display Modes
Old Unix and Linux 04-06-2012   -   Original Discussion by Blogger11
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
Old Unix and Linux 04-08-2012   -   Original Discussion by Blogger11
kevintse's Unix or Linux Image
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:

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

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

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux 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 06:42 PM
Script to monitor JBoss web server nsachin Shell Programming and Scripting 2 11-13-2009 01:53 PM
Recycle Bin Script chueu Shell Programming and Scripting 2 05-21-2009 01:21 AM
JBoss Application Server 5 CR1 available Linux Bot Red Hat 0 09-11-2008 11:07 AM

All times are GMT -4. The time now is 03:28 AM.