1

I currently run these java applications with the following command via root: java -Xms1G -Xmx1G -jar /var/www/tekkit.socialnetwk.com/tekkit.jar nogui

Although if I close the terminal window those applications close/stop. Is there anyway to stop this from happening? Either creating it as a service or to start it on boot. I've tried rc.local but no luck.

I'm running on Ubuntu - Newest.

1 Answers1

3

In the past I have done two things to make a process run after the terminal shuts down... use ampersand to run it in the background and nohup so that it does not get killed by the terminal closing.

nohup java -Xms1G -Xmx1G -jar /var/www/tekkit.socialnetwk.com/tekkit.jar nogui &

EDIT: Here is a great answer that goes into detail. Upvote that answer instead since it is way more complete.

Community
  • 1
  • 1
Jose Martinez
  • 11,452
  • 7
  • 53
  • 68
  • 1
    you may want to also redirect both outputs into a file by `&>> logfile`. So: `nohup java -Xms1G -Xmx1G -jar /var/www/tekkit.socialnetwk.com/tekkit.jar nogui &>> logfile &` – Jiri Kremser Aug 11 '15 at 15:52
  • Should I get this output? nohup: ignoring input and appending output to ‘nohup.out’ – 5SpeedNoReverse Aug 11 '15 at 15:59
  • First, hopefully your Java process has good logging that you can rely on. You can either get comfortable with viewing nohop.out or if you want the stdout/stderr to go to a different file then use the redirect that @JiriKremser suggested. – Jose Martinez Aug 11 '15 at 16:02