jvm - How to execute the specified command when java exits abnormally
PHPz2017-05-17 10:00:01
0
1
482
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. .
你说的异常退出是jvm crash掉吗?还是仅仅抛出OOM之类的Error?
如果是前者,那任何措施都无法保证你记录系统的状态,很有可能像
TerminateProcess
和kill -9
一样,进程会不留痕迹地消失。如果是后者的话,
addShutdownHook
就应该能做到的。