2

I am using ubuntu 14.04

I am running a jar file which should be collection a large amount of data for a few days.

I am running the jar file thought this command and it works fine.

java -jar xxx.jar

However when i close the putty, the process stopped. Is there a way for a jar file to run even when i close the putty?

Chit Khine
  • 830
  • 1
  • 13
  • 34
  • [Tmux](https://tmux.github.io/) is installed by default (I think) on Ubuntu. Use that. – Boris the Spider Feb 18 '17 at 10:04
  • You can run it as system service using upstart or systemD scripts e.g. In that way the OS handles the running of the jar. Something like `sudo service yourApp start/stop/restart/satuts` – rocksteady Feb 18 '17 at 10:55

3 Answers3

3

You can use nohup to run the jar(any process) in background.

Use the following command in the putty session :

nohup java -jar xxx.jar &
Sandesh Gupta
  • 1,175
  • 2
  • 11
  • 19
0

You need the nohup command. This command makes processes keep running despite closing terminal.

Run your jar with (in case you are in the right folder):

 nohup java -jar xxx.jar &
n00bst3r
  • 637
  • 2
  • 9
  • 17
0

I would suggest to you use

nohup java -jar xxx.jar > /dev/null 2>&1 &

which redirects standard error & output of the command to /dev/null which means it's discarded. If you need the console output of this command then you can redirect it to any file as follows

nohup java -jar xxx.jar > output.log 2>&1 &
Gowtham
  • 624
  • 5
  • 9