Just before the java process exits abnormally, how to execute the specified command to retain the state of the system at that time? I saw a blog on the Internet that said that commands can be executed, but there was no specific explanation. .
大家讲道理2017-05-17 10:02:01
Is the abnormal exit you are talking about a jvm crash? Or just throw an Error like OOM?
If it is the former, then no measures can guarantee that you will record the status of the system. It is very likely that like TerminateProcess
and kill -9
, the process will disappear without leaving a trace. TerminateProcess
和kill -9
一样,进程会不留痕迹地消失。
如果是后者的话,addShutdownHook
If it’s the latter, addShutdownHook
should be able to do it.