Running Direct and/or Workflow/Webmail on Linux - ulimit - too many open files
Posted by John Tkaczewski, Last modified by Aly Essa on 04 August 2016 12:03 PM

If you installed FC Direct / Webmail / Workflow on Linux/Unix and after a few hours of Tomcat or FC Server running you notice that the server is not responding or image files are not loading or Java applets are not loading. Or you see an error "Too many open files" in the logs. Make sure that you don't have any limits for maximum open files. 


To view all available resource limits, type ulimit -a.

ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
file size (blocks, -f) unlimited
pending signals (-i) 8191
max locked memory (kbytes, -l) 32
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 8191
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited


You can use "ulimit -n" to change the lopen files limit. You should increase the open files limit to at lease 60000.
This parameter must be changed by the user who runs tomcat and that it must be done each time prior to starting tomcat.

More on ulimit...

ulimit provides control over the resources available to the shell and to processes started by it, on systems that allow such control.

Usually, you have to increase the values of some of the Linux kernel limits before your install or run many applications.

With ulimit you can set two kind of limits:

1. Soft limit: is the value that the kernel enforces for the corresponding resource.
2. Hard limit:
acts as a ceiling for the soft limit.

An unprivileged process may only set its soft limit to a value in the range from 0 up to the hard limit, and (irreversibly) lower its hard limit. A privileged process may make arbitrary changes to either limit value.

Checking the values of the kernel limits

# ulimit -a
core file size (blocks, -c) 1
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 59517
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) 6695364
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 59517
virtual memory (kbytes, -v) 6301520
file locks (-x) unlimited

Changing temporally the value of a limit

With ulimit you can change the value of one limit for the current shell:

# ulimit -n 60000

This command sets the maximum number of opened files to 60000 for the current shell.

Making permanent changes to a limit

Linux servers have a PAM (plugabble authentication) module that handles system limits:

“By default limits are taken from the /etc/security/limits.conf config file. Then individual files from the /etc/security/limits.d/ directory are read. The files are parsed one after another in the order of “C” locale. The effect of the individual files is the same as if all the files were concatenated together in the order of parsing. If a config file is explicitely specified with a module option then the files in the above directory are not parsed.”

In our example we will set the maximum number of files to 16384 for all users of the system (values can be set for individual users or groups as well):

# vi /etc/security/limits.conf

Add two lines for each limit:

* soft nofile 60000
* hard nofile 60000

Reboot your machine and test the new limits configuration:

# ulimit -a
core file size (blocks, -c) 1
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 59517
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) 6695364
open files (-n) 60000
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 59517
virtual memory (kbytes, -v) 6301520
file locks (-x) unlimited