Java 接收邮件崩溃时执行
Java executed when receiving mail crashes
我想做什么
我想在收到电子邮件时 运行 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 的 运行 工作正常
运行 bash mailtrigger.sh
来自 CLI 工作正常。
/tmp/mailtest/stdout.log
start
success
end
当 运行 来自电子邮件
时崩溃
执行命令mail -s test mail@example.local
后,变成如下
/tmp/mailtest/stdout.log
电子邮件已正确接收,sh 正在 运行ning。但是,输出如下错误文件。
/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)
如果没有足够的信息,我很抱歉。
我会添加必要的信息。
有麻烦了。帮我。请。
原因是 SELINUX。
我临时把SELINUX改成了Permissive,成功了。
非常感谢。
我想做什么
我想在收到电子邮件时 运行 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 的 运行 工作正常
运行 bash mailtrigger.sh
来自 CLI 工作正常。
/tmp/mailtest/stdout.log
start
success
end
当 运行 来自电子邮件
时崩溃执行命令mail -s test mail@example.local
后,变成如下
/tmp/mailtest/stdout.log
电子邮件已正确接收,sh 正在 运行ning。但是,输出如下错误文件。
/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)
如果没有足够的信息,我很抱歉。 我会添加必要的信息。
有麻烦了。帮我。请。
原因是 SELINUX。 我临时把SELINUX改成了Permissive,成功了。 非常感谢。