2

What i want to do

I want to run the jar when I receive an email. I wrote the configuration file as follows.

/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

Running from CLI works fine

Running bash mailtrigger.sh from CLI works fine.

/tmp/mailtest/stdout.log

start
success
end

Crash when run from email

When the command mail -s test mail@example.local is executed, it becomes as follows.

/tmp/mailtest/stdout.log

The email was received correctly and sh is running. However, the following error file is output.

/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
#

Memory seems to be enough

I think that it is enough because the memory is not insufficient even if it is executed from the CLI. I will write the following just in case.

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

Not only jar but java -version doesn't work

Rewriting the sh file as follows also crashed.

/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

Of course it succeeds from the 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)

Other information

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

I'm sorry if there is not enough information. I will add the necessary information.

in trouble. help me. Please.

fsk5304
  • 395
  • 1
  • 3
  • 11

1 Answers1

0

The cause was SELINUX. I temporarily changed SELINUX to Permissive and it was successful. Thank you very much.

fsk5304
  • 395
  • 1
  • 3
  • 11