【问题标题】:Java executed when receiving mail crashes接收邮件时执行的 Java 崩溃
【发布时间】:2021-02-17 00:37:13
【问题描述】:

我想做什么

我想在收到电子邮件时运行 jar。 我写的配置文件如下。

/etc/aliases

mail: mailuser,| "/bin/bash /tmp/mailtest/mailtrigger.sh"

/tmp/mailtest/mailtrigger.sh

#!/bin/bash
echo start >> /tmp/mailtest/stdout.log
java -jar /tmp/mailtest/example.jar
echo end >> /tmp/mailtest/stdout.log

从 CLI 运行正常

从 CLI 运行 bash mailtrigger.sh 工作正常。

/tmp/mailtest/stdout.log

start
success
end

从电子邮件运行时崩溃

mail -s test mail@example.local命令执行时,变成如下。

/tmp/mailtest/stdout.log

电子邮件已正确接收并且 sh 正在运行。但是,输出如下错误文件。

/tmp/mailtest/stdout.log

start
end

tmp/hs_err_pid32575.log

# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 2555904 bytes for committing reserved memory.
# Possible reasons:
#   The system is out of physical RAM or swap space
#   The process is running with CompressedOops enabled, and the Java Heap may be blocking the growth of the native heap
# Possible solutions:
#   Reduce memory load on the system
#   Increase physical memory or swap space
#   Check if swap backing store is full
#   Decrease Java heap size (-Xmx/-Xms)
#   Decrease number of Java threads
#   Decrease Java thread stack sizes (-Xss)
#   Set larger code cache with -XX:ReservedCodeCacheSize=
#   JVM is running with Unscaled Compressed Oops mode in which the Java heap is
#     placed in the first 4GB address space. The Java Heap base address is the
#     maximum limit for the native heap growth. Please use -XX:HeapBaseMinAddress
#     to set the Java Heap base and to place the Java Heap above 4GB virtual address.
# This output file may be truncated or incomplete.
#
#  Out of Memory Error (os_linux.cpp:2753), pid=28040, tid=0x00007fca156d3700
#
# JRE version:  (8.0_212-b04) (build )
# Java VM: OpenJDK 64-Bit Server VM (25.212-b04 mixed mode linux-amd64 compressed oops)
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#

内存好像够用了

我认为足够了,因为即使从 CLI 执行,内存也不会不足。 为了以防万一,我会写以下内容。

vmstat

procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 1  0  50176 807536      0 391192    0    0     1     2   39   35  4  3 93  0  0

不仅 jar,而且 java -version 都不起作用

如下重写sh文件也崩溃了。

/tmp/mailtest/mailtrigger.sh

#!/bin/bash
echo start >> /tmp/mailtest/stdout.log
#java -jar /tmp/mailtest/example.jar
java -version
echo end >> /tmp/mailtest/stdout.log

当然,它从 CLI 成功。

 java -version
openjdk version "1.8.0_212"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_212-b04)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.212-b04, mixed mode)

其他信息

postconf | grep mail_version
mail_version = 2.10.1
cat /etc/system-release
CentOS Linux release 7.5.1804 (Core)

如果没有足够的信息,我很抱歉。 我会添加必要的信息。

有麻烦了。帮我。请。

【问题讨论】:

    标签: java linux spring-boot sh postfix-mta


    【解决方案1】:

    原因是 SELINUX。 我暂时把 SELINUX 改成 Permissive 就成功了。 非常感谢。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-11
      • 1970-01-01
      • 1970-01-01
      • 2014-07-19
      • 1970-01-01
      相关资源
      最近更新 更多