After SSH'ing into an EC2 instance running the Amazon Linux AMI, I tried:
ulimit -n 20000
...and got the following error:
-bash: ulimit: open files: cannot modify limit: Operation not permitted
However, the shell allows me to decrease this number, for the current session only.
Is there anyway to increase the ulimit on an EC2 instance (permanently)?
In fact, changing values through the ulimit
command only applies to the current shell session. If you want to permanently set a new limit, you must edit the /etc/security/limits.conf
file and set your hard and soft limits. Here's an example:
# <domain> <type> <item> <value>
* soft nofile 20000
* hard nofile 20000
Save the file, log-out, log-in again and test the configuration through the ulimit -n
command. Hope it helps.
P.S. 1: Keep the following in mind:
P.S. 2: Additional files in /etc/security/limits.d/
might affect what is configured in limits.conf
.