Linux How to clear hs_err_pid log file in home directory
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7349762/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to clear hs_err_pid log file in home directory
提问by kelvinfix
I have lots of log file in my home directory:
I have lots of log file in my home directory:
hs_err_pid2326.log
hs_err_pid2416.log
I believe it is a java error log file, how to remove it and stop creating them?
I believe it is a java error log file, how to remove it and stop creating them?
Java version:
Java version:
[kelvin@localhost ~]$ java -version
java version "1.6.0_21"
Java(TM) SE Runtime Environment (build 1.6.0_21-b06)
Java HotSpot(TM) Server VM (build 17.0-b16, mixed mode
采纳答案by Ernest Friedman-Hill
They are created if and when the JVM crashes; they're analogous to a core
file, but contain a lot of Java-specific information. They're just text files, and you can delete them like you would any other files:
They are created if and when the JVM crashes; they're analogous to a core
file, but contain a lot of Java-specific information. They're just text files, and you can delete them like you would any other files:
$ rm ~/hs_err_pid*.log
You can stop creating them by no longer crashing the JVM. Normally, such crashes are rare. Look at the files themselves in a text editor and they will contain some info about their origins.
You can stop creating them by no longer crashing the JVM. Normally, such crashes are rare. Look at the files themselves in a text editor and they will contain some info about their origins.
回答by adarshr
These are Java crash (core) dump log files. Identify which Java process creates them by tracing and monitoring the PID.
These are Java crash (core) dump log files. Identify which Java process creates them by tracing and monitoring the PID.
回答by Francois Corthay
Have a shutdown script to delete these files.
Have a shutdown script to delete these files.
With systemd
, create a script deleting those files, e.g. /home/user/cleanJavaLogs.bash
:
With systemd
, create a script deleting those files, e.g. /home/user/cleanJavaLogs.bash
:
rm /home/user/hs_err_pid*
Then create a service descriptor file /etc/systemd/system/clearJavaLogs.service
containing:
Then create a service descriptor file /etc/systemd/system/clearJavaLogs.service
containing:
[Unit]
Description=Clear Javascript "hs_err_pidnnnn.log" files on shutdown
DefaultDependencies=no
Before=shutdown.target reboot.target halt.target
[Service]
Type=oneshot
ExecStart=/home/user/cleanJavaLogs.bash
[Install]
WantedBy=halt.target reboot.target shutdown.target
and activate the service:
and activate the service:
systemctl enable clearJavaLogs.service