views:

317

answers:

3

Hello.

I have inherited a java system which should be run in the background on a Linux server. The directions call for it to be started java -jar start.jar. This seems a little too fragile for my liking. I'd like it to actually run in the background, ideally starting up automatically at boot time.

What is the best way to achieve this? I've looked into running the system within a screen environment, which works fine, but won't automatically start up when the system reboots.

+6  A: 

You can write an init rd script for it! (init.rd scripts are started in specified runlevels at startup time)

Or you can start it in the background with & in the end of the command.

java -jar start.jar &

What kind of distribution do you use? Debian?

Have a look at: Creating your own init.rd script

Martin K.
+1  A: 

At least on ubuntu, I'd put this command in the /etc/rc.local file with an & at the end.

krosenvold
+1  A: 

+1 on using an init.d script

You should also consider using jsvc (http://commons.apache.org/daemon/jsvc.html) in your init.d script to allow you to use privileged resources while running the service as an unprivileged user. jsvc is bundled with at least Debian and Ubuntu.

stephen mulcahy