Can you override file permissions for the heap heap created by -XX + HeapDumpOnOutOfMemoryError?

On Linux, when used, the -XX+HeapDumpOnOutOfMemoryErrorcreated hprof file belongs to the user in which the Java process runs and has 600 permissions.

I understand that these permissions are best secure, but can I override them?

+5
source share
2 answers

You can start the JVM with

java -XX:+HeapDumpOnOutOfMemoryError -XX:OnOutOfMemoryError="chmod g+r java_pid*.hprof" {mainclass} {args}

The command runs after heap dump. This will allow access to the group to view all heap dump files in the current directory, for example.

+4
source

The parameter -XX:OnOutOfMemoryErrordoes not work for me with spaces in the JRE 7 command (1.7.0_72). But point to shell script (no spaces). Example:

-XX: OnOutOfMemoryError = "//// script.sh"

0

All Articles