start jboss server and run in back ground

i start the jboss app server with below command from putty session and let it run in background, but when i close my putty session the jboss server will be stopped. How make the jboss run in back ground with out interruption even when i disconnect my putty session.

/app/papa/jboss-5.1.0.GA/bin/run.sh -c all -b 192.77.88.129 &
wasmanIT AnalystAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

xtermCommented:
I would suggest creating a sysv init script which starts it at boot time, and then shuts it down cleanly before a reboot.  This is pretty simple to do (and you can you a cron to fire it up the first time so that you don't have to reboot to get it started)

If you tell me which OS you're running, I'll help you create it.
0
wasmanIT AnalystAuthor Commented:
linux centos 5.7 (which is equalent to redhat5.7)
0
xtermCommented:
- Create this script as /etc/init.d/jboss
- Make it executable with "chmod 755 /etc/init.d/jboss"
- Make it start at boot time with "/sbin/chkconfig --levels 2345 jboss on"

You can modify the stop() function to put in however you normally shut it down.

Test it by manually stopping/starting your server with:

/etc/init.d/jboss start
/etc/init.d/jboss stop

That's it!  If the above works fine, then it will be automatic from now on.

#!/bin/bash
#
# chkconfig: 2345 85 15
# description: This script will start jboss in runlevels 2-5
# processname: jboss
# pidfile: /var/run/jboss.pid
# config: /etc/sysconfig/jboss

# source function library
. /etc/init.d/functions

if test -e /etc/sysconfig/jboss ; then
    . /etc/sysconfig/mouse
fi

RETVAL=0

if [ -z $1 ]; then
        echo "Usage: `basename $0` [start|stop]"
        exit 1
fi

case "$1" in
  start)
        /app/papa/jboss-5.1.0.GA/bin/run.sh -c all -b 192.77.88.129 &
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/jboss
        ;;
  stop)
        # CHANGE THIS TO WHATEVER YOUR SHUTDOWN COMMAND IS
        /app/papa/jboss-5.1.0.GA/bin/stopserver.sh
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/jboss
        ;;
esac

exit $RETVAL

Open in new window

0
IT Pros Agree: AI and Machine Learning Key

We’d all like to think our company’s data is well protected, but when you ask IT professionals they admit the data probably is not as safe as it could be.

xtermCommented:
Line #13 should be

    . /etc/sysconfig/jboss


Sorry, I copied another script to use as an example.  This won't affect it running, but please correct it anyway :)
0
wasmanIT AnalystAuthor Commented:
it working but when i run /etc/init.d/jboss start it's starting the server and then it neve comes back to command prompt and if i close the puitty session it will kill the jboss server as my initial concern is.

and also when i do ctrl+Z  when it won't come back to prompt, the server goes down but i get below error

15:56:07,866 INFO  [HypersonicDatabase] Database standalone closed clean
15:56:11,265 INFO  [ServerImpl] Shutdown complete
Shutdown complete
Halting VM

touch: cannot touch `/var/lock/subsys/jboss': Permission denied
0
xtermCommented:
Put between line 24&25 this:

export LAUNCH_JBOSS_IN_BACKGROUND=1

Then try again, it should work.
0
wasmanIT AnalystAuthor Commented:
now it runs even i disconnect my putty session, but it doesn't come back to unix prompt when run /etc/init.d/jboss start and when i do crtl+z i still get --> " touch: cannot touch `/var/lock/subsys/jboss': Permission denied"

and

i run jboss instance as webadmin user account, i noticed boot process it starting server as root process when i reboot the OS.

0
xtermCommented:
Just comment out the /var/lock/subsys lines in the script if you're not running it as root - you don't need them.

And don't worry about it not coming back to the prompt - it's working after you disconnect, which is what you wanted.

And the bonus is that from now on, it will start when you boot up too!
0
wasmanIT AnalystAuthor Commented:
it works now....cool...what is this for "var/lock/subsys"

Thanks a lot for helping me out
0
wasmanIT AnalystAuthor Commented:
oh it is still starting as root after i reboot my OS, below is your script

sudo vi /etc/init.d/jboss
#!/bin/bash
#
# chkconfig: 2345 85 15
# description: This script will start jboss in runlevels 2-5
# processname: jboss
# pidfile: /var/run/jboss.pid
# config: /etc/sysconfig/jboss

# source function library
. /etc/init.d/functions

if test -e /etc/sysconfig/jboss ; then
    . /etc/sysconfig/jboss
fi

RETVAL=0

if [ -z $1 ]; then
        echo "Usage: `basename $0` [start|stop]"
        exit 1
fi

case "$1" in
  start)
      export LAUNCH_JBOSS_IN_BACKGROUND=1
      /app/govi/apache2.2.21/bin/apachectl start
        /app/govi/jboss-5.1.0.GA/bin/run.sh -c all -b 192.168.254.129
        RETVAL=$?
        echo
        #[ $RETVAL -eq 0 ] && touch /var/lock/subsys/jboss
        ;;
  stop)
        # CHANGE THIS TO WHATEVER YOUR SHUTDOWN COMMAND IS
      /app/govi/apache2.2.21/bin/apachectl stop
        /app/govi/jboss-5.1.0.GA/bin/shutdown.sh -S
        RETVAL=$?
        echo
        #[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/jboss
        ;;
esac

exit $RETVAL
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
xtermCommented:
If you want it to start as some other user, you can try changing these lines:

   /app/govi/apache2.2.21/bin/apachectl start
   /app/govi/jboss-5.1.0.GA/bin/run.sh -c all -b 192.168.254.129

to

   su webadmin -c "/app/govi/apache2.2.21/bin/apachectl start"
   su webadmin -c "/app/govi/jboss-5.1.0.GA/bin/run.sh -c all -b 192.168.254.129"

I haven't tested that - it wasn't really part of your original question.

/var/lock/subsys is simply a folder where processes open a file to let the system know that they are running for status purposes.
0
wasmanIT AnalystAuthor Commented:
perfect it's starting as non-root user now. although the /etc/sbin/jboss start command still does run in background when i disconnect the putty seesion it will stop the jboss server.

But i am able to start the jboss from the boot
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Application Servers

From novice to tech pro — start learning today.