SBE
SBE

Reputation: 13

Java service auto kill on linux

I have ran nohup java -jar sample.jar & on my linux server as a backend service of web application but service is automatically killed after few hours and need to re-run the command. I want to know what is the reason and how to resolve the issue

Upvotes: 1

Views: 935

Answers (2)

Stephen C
Stephen C

Reputation: 718778

On Linux, one possibility is that it is the oomkiller process. This watches for processes that appears to be triggering excessive paging activity, and sends them a SIGKILL signal. The oom killer's purpose is to prevent the paging system from thrashing ... which can bring the entire system to its knees.

If it is the oom killer killing your Java app, you should see a log message in /var/log/messages or /var/log/syslog.

The solution may be as simple as reducing the Java app's heap size so that it all fits in the available physical memory. Alternatively, if your Java app's heap usage is growing all of the time, you may need to look for a possible memory leak in your app. (Search for articles on finding Java memory leaks ...)

Upvotes: 1

gshauger
gshauger

Reputation: 745

I run Spring Boot via the same command and only a handful of times have I seen this behavior. It turned out that the JVM ran out of memory and it crashed. When I changed the heap size settings it was rock solid again.

Upvotes: 0

Related Questions