how to run a jar file on the ubuntu 14.04 without

2019-07-12 19:56发布

问题:

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?

回答1:

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 &


回答2:

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 &


回答3:

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 &