简体   繁体   English

Java进程在Linux上崩溃(Ubuntu 14.04)

[英]Java process crashes on Linux (ubuntu 14.04)

I have a Java process ran from shell script on Ubuntu 14.04, that crashes abnormally without any visible reason and no logs. 我在Ubuntu 14.04上从外壳程序脚本运行了一个Java进程,该进程异常崩溃,没有任何明显的原因,也没有日志。 The Java program uses Twitter's Userstream API. Java程序使用Twitter的Userstream API。 I've been looking for traces in /var/log but did not find anything that could explicitly point to a problem. 我一直在/ var / log中寻找跟踪,但是没有发现任何可以明确指出问题的东西。 Please advise how approach this issue and find any useful log that could indicate the problem. 请告知如何解决此问题,并找到任何可能表明该问题的有用日志。 Also, this is my Java version: 另外,这是我的Java版本:

Java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)

The first step in troubleshooting HotSpot crashes is to locate a crash log, alternatively called fatal error log. 解决HotSpot崩溃的第一步是找到崩溃日志,或者称为致命错误日志。 By default, these are named hs_err_pid%pid.log , with %pid being the process ID of the crashed VM, and can usually be found in the cwd where the process started. 默认情况下,它们被命名为hs_err_pid%pid.log ,其中%pid是崩溃的VM的进程ID,通常可以在进程启动的cwd中找到。 The name and location of said log can also be influenced through the -XX:ErrorFile -VM parameter. 所述日志的名称和位置也可以通过-XX:ErrorFile -VM参数来影响。 Example: 例:

-XX:ErrorFile=/var/log/java/java_error%pid.log . -XX:ErrorFile=/var/log/java/java_error%pid.log

You can find more information about the crash logs themselves here . 您可以在此处找到有关崩溃日志本身的更多信息。

The contents of that log can give an indication on what happened, and where approximately. 该日志的内容可以指示发生了什么以及大概在哪里。 Be prepared tho, that situations in which a HotSpot crash occurs, are usually not caused by mere bugs in the hosted Java program. 请做好准备,以防止发生HotSpot崩溃的情况通常不是仅由托管Java程序中的错误引起的。 An extensive guide to interpreting these crash logs can be found here here . 这里可以找到解释这些崩溃日志的详尽指南。

If no such log can be located after a crash, odds are the VM did not crash, but terminated normally. 如果在崩溃后找不到此类日志,则可能是VM没有崩溃,而是正常终止了。 In that case, a remote debugging session might be in order. 在这种情况下,可能会进行远程调试会话。 Remote debugging is detailed here and also has some topics on SO already. 远程调试在这里详细介绍并且已经有一些关于SO的主题。

(There's the very remote chance that circumstances do not permit the log to be written, ie no available file handles during the crash.) (在极少数情况下,情况不允许写入日志,即崩溃期间没有可用的文件句柄。)

The problem was that my process terminated when I disconnected SSH from the server. 问题是当我从服务器断开SSH时,我的进程终止了。 In order to run the process in background and prevent process termination when disconnected use 'nohup': 为了在后台运行进程并防止断开连接时进程终止,请使用“ nohup”:

~$ nohup process_name & 〜$ nohup process_name

I found the answer in this thread . 我在此线程中找到了答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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