Monday, November 15, 2021

ARG_MAX limitation cause Argument list too long Error


While trying to send an HTML Email, I was getting below error due to the big Email body (which was embedded inside SENDMAILARGS variable:

 Argument list too long


This is due to the maximum length of an argument command in Linux which is controlled by ARG_MAX parameter, you can view the value of this parameter using this command: [Value is in Bytes]

# getconf ARG_MAX


In a nutshell, ARG_MAX represent 25% of the Stack size; which means if we increase the Stack size; this will increase the ARG_MAX limit too.

Current Stack size can be viewed using this command: [Value is in KB]

# ulimit -s

To increase the Stack size:

 # ulimit -s 20240

Let's check the value of ARG_MAX after increasing the Stack size:

Please note that this change happen to the current session only, in case you want to increase the Stack size permanently for all new sessions, you have to change the Stack size value in /etc/security/limits.conf

No comments:

Post a Comment