我对应该是一个简单的任务感到恼火: java进程正在运行,内存耗尽,脚本运行。
禁用SELinux 。
在setenv.sh中:
-XX:OnOutOfMemoryError='/opt/alfresco/scripts/dumpNrestart.sh > /tmp/dumpNrestart.log 2>&1'在/etc/sudoers.d/alfresco_sudoers中:
%alfresco ALL= NOPASSWD: /opt/alfresco/java/bin/jcmd在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在bash上运行dumpNrestart.sh,使用非特权用户,而当JVM调用它(与同一个用户一起运行)时,它不起作用:
++ 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.(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我想这是一个权限/特权问题,但是我认为我已经完成了.但我不像我们看到的那样。
有什么想法,我可以试试吗?
谢谢你花时间阅读这篇文章!
发布于 2022-04-04 23:20:39
尝试使用& .This将使脚本在后台运行。它就能进入。
-XX:OnOutOfMemoryError='sh /opt/al新鲜XX/script/dumpNrestart.sh &‘
https://serverfault.com/questions/1078887
复制相似问题