I'm getting mad with what should be a simple task: a java process is running, runs out of memory and a script runs.
SELinux is disabled.
in setenv.sh :
-XX:OnOutOfMemoryError='/opt/alfresco/scripts/dumpNrestart.sh > /tmp/dumpNrestart.log 2>&1'
in /etc/sudoers.d/alfresco_sudoers :
%alfresco ALL= NOPASSWD: /opt/alfresco/java/bin/jcmd
in dumpNrestart.sh :
#!/bin/sh -x
PIDDE=$(cat /opt/alfresco/tomcat/temp/catalina.pid)
/bin/rm -f /tmp/"$PIDDE".hprof
/bin/sudo /bin/id
/bin/sudo /opt/alfresco/java/bin/jcmd "$PIDDE" GC.heap_dump /tmp/"$PIDDE".hprof
/opt/alfresco/tomcat/bin/shutdown.sh -force
Running dumpNrestart.sh from bash, with an unprivileged user works while it doesn't when called by the JVM (that runs with the same user):
++ cat /opt/alfresco/tomcat/temp/catalina.pid
+ PIDDE=11451
+ /bin/rm -f /tmp/11451.hprof
+ /opt/alfresco/java/bin/jcmd 11451 GC.heap_dump /tmp/11451.hprof
11451:
com.sun.tools.attach.AttachNotSupportedException: Unable to open socket file /proc/11451/root/tmp/.java_pid11451: target process 11451 doesn't respond within 10500ms or HotSpot VM not loaded
at jdk.attach/sun.tools.attach.VirtualMachineImpl.<init>(VirtualMachineImpl.java:100)
at jdk.attach/sun.tools.attach.AttachProviderImpl.attachVirtualMachine(AttachProviderImpl.java:58)
at jdk.attach/com.sun.tools.attach.VirtualMachine.attach(VirtualMachine.java:207)
at jdk.jcmd/sun.tools.jcmd.JCmd.executeCommandForPid(JCmd.java:114)
at jdk.jcmd/sun.tools.jcmd.JCmd.main(JCmd.java:98)
+ /opt/alfresco/tomcat/bin/shutdown.sh -force
I guess it is a permission/privilege issue but with sudo I thought I was done... but I'm not as we see.
Any ideas, something I could try?
Thanks for your time reading this!