how to run a jar file on the ubuntu 14.04 without stopping when i stopped the putty?

♀尐吖头ヾ 提交于 2019-12-11 01:37:45

问题


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 &


来源:https://stackoverflow.com/questions/42313704/how-to-run-a-jar-file-on-the-ubuntu-14-04-without-stopping-when-i-stopped-the-pu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!