Skip to content

Instantly share code, notes, and snippets.

@kirkch
Created August 24, 2012 14:07
Show Gist options
  • Save kirkch/3450993 to your computer and use it in GitHub Desktop.
Save kirkch/3450993 to your computer and use it in GitHub Desktop.
Changing ulimit on Ubuntu
Verification
Check your system limits:
$ cat /proc/sys/fs/file-max
$ sysctl -a |grep fs.file-max
To check the number of file descriptors used by any given process use
$ ls -la /proc/<pid>/fd
or use the lsof (LiSt Open Files) command
$ lsof -p <pid of process>
or (my favourite)
$ lsof -p <pid> | wc -l
non of the above were sufficient under Ubuntu. Please run
$ ulimit -n
1024 is too few. Note that ulimit is built into bash, not a program of its own. If you use something else, type bash to change the shell for the ulimit command. Please apply both steps of the following solution
Solution
System wide limit change
Change limit by editing /etc/sysctl.conf and set fs.file-max to 400000
Then run
$ sysctl -p
to apply your changes to your system. May need reboot.
Per user/process limit change
For Linux systems running PAM (that is e.g. Ubuntu) you will need to adjust /etc/security/limits.conf
tomcatservice hard nofile 5000
ulimit -n5000 has not worked for me in the past, but can always give it a try.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment