简体   繁体   中英

Nohup java process timeout or killed

I have a java application which is compiled and packed as Jar file. It contains a while(true) loop inside the application.

My main problem is this, when i run my application in unix server by using

nohup java -jar processName.jar > log.txt

it starts well. After a while(i do not know the reason, and log file does not exist any exception) it seems to shut down. I can see the process by ps -ef but log file and output file does not change at all.


Does nohup process shuts down after a while? Does it have any timeout or any configuration I have to make? And what is the best way to create background process at server?

Nohup won't stop unless the program exits or you interrupt the process (this includes you disconnecting from an ssh shell). To launch the program in the background, add an ampersand (&) after the command: nohup java -jar processName.jar > log.txt &

Screen can also be useful if you want to easily kill it later.

If it's still stopping when run in the background, something in the Java code is silently exiting, so investigate there.

And one additional possibility -- on some machines, low-priority cpu-hogging programs can get killed automatically. If your while loop isn't ever yielding, this (though unlikely) might be the reason the process is getting shut down.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM