HOWTO Run a java chatserver application as a service under LINUX

Hello,

I have managed to create a chat server java application. It works fine, when i start it on the command line. However, when i close my ssh session it closes down ofcourse. I would like
to have this program running forever ( as a service or something else ) and dont want to stay logged in all the time.

Is there an easy way to do this ? I'm average experienced on windows platforms but am a novice on LINUX.

Hope someone can point me out or refer me to a tutorial that covers this clearly.

Thanks!

Marcel
LVL 2
marcel42Asked:
Who is Participating?
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.

girionisCommented:
Try to start it by using: java <your class> &
0
girionisCommented:
Alternatively you can put the above command on your .bashrc or .bash_profile and have it start automatically upon computer/shell start up.
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
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

marcel42Author Commented:
Ok thanks, do you know how to close down this service again ? Just kill it with the kill command ? Or is there a cleaner method ?
0
TimYatesCommented:
http://wrapper.tanukisoftware.org/doc/english/introduction.html

Is a wrapper to allow your application to run as either a Windows service, or a UNIX Daemon :-)

Tim
0
girionisCommented:
> Ok thanks, do you know how to close down this service again ? Just kill
> it with the kill command ? Or is there a cleaner method ?

How do you stop it normally?

Kill would do. Alternatively you could write a script that sends a signal to it in order to stop, something similar to how the Tomcat start/stop is done.
0
petmagdyCommented:
u can search for the Java proccess and kill it by the Id
0
TimYatesCommented:
>  Try to start it by using: java <your class> &

This would still be killed when you logged out (I think)

A more stable version of this would be:

nohup java yourclass & > /tmp/nohup.out

the "nohup" tells the process no to die when you log off (and it gets sent a SIG_INT command to shut down)

I *think* ;-)
0
TimYatesCommented:
Also, I don't think .bashrc is read until you log in, so I am not sure that the process would start when the computer powered up...

(Oh, and SIG_INT in my previous comment should be SIG_HUP obviously) ;-)

Basically, you will either want to write a script to put in /etc/rc.d/init.d/ to allow /sbin/service to start, stop and restart your service, or use that wrapper from tanukisoftware (which is probably easier to use -- init.d scripts make my brain melt sometimes :-(
0
girionisCommented:
I think you are right about the "nohup"
0
CEHJCommented:
Tim's last comments are the ones you need
0
girionisCommented:
:)
0
zzynxSoftware engineerCommented:
Thank you
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
Java

From novice to tech pro — start learning today.