Troubleshooting
Problem
Symptom
- Too Many Open Files
- Could not lock User prefs. Unix Error Code 24.
- Truncated core dumps or heapdumps
- Is it possible to display the current ulimit settings?
- How are ulimits set?
- Specifics for each Operating System
- If I am experiencing Too Many Open Files (Unix Error Code 24), can I increase the number of file descriptors?
- On Linux, can I set the ulimit for the number of open files to unlimited?
- I am using an /etc/init.d script (or inittab) to start my application server and setting the global ulimit settings had no effect?
Resolving The Problem
However, if a process is already running, it can have a different ulimit configuration than the current shell that you run the ulimit -a command in.
Soft limits are the current setting for a particular limit. They can be increased only to the current hard limit setting.
Hard limits are the maximum limit that can be configured. Any changes to these require root access.
Temporary Settings (for current session)
- ulimit -[H|S]limit_name limit_value
Temporary settings are configured on the command line by using the ulimit command. The limit_name must be present in the command (see the table). These settings are only temporary for the current session and are lost when the session is over or the terminal window is closed.
This syntax can be used within shell scripts. Any processes forked from these shell scripts also have the temporary settings for the lifetime they are running.
By default, the soft limit is changed (as changing the hard limit needs root access). Use -H (for hard limits) or -S (for soft limits) to change specific hard or soft limits.
NOTES:
On HP-UX, if you receive an error setting a particular limit, usually a hard limit, see whether it exceeds the kernel parameters. You can use kctune to check (and alter) the limits if necessary; check your HP-UX documentation for more information about this topic.
For Solaris, settings in the "/etc/system" configuration file also allow configuring of some kernel-wide limits.
Global Settings
Any changes to these global configuration limits files need to be performed by a system administrator. Instructions on how to edit the files can be found on the man page or in the commented section of the configuration file, as they can vary between versions of UNIX or Linux.
The format of the file, which differs slightly on versions of AIX and Linux, allows individual limits per users or groups, as well as set hard and soft limits. The limits defined in this configuration file are set globally.
Changes made to any limits file take effect in a new login shell (such as bash -l), or if the user logs out and logs back in to the system.
NOTES:
On Solaris and HP-UX, changes made to your shell's profile configuration (.profile or .login) also takes effect on the next login shell launched, or when your user logs back in using the specific shell.
For kernel-wide settings, which usually require a restart of the operating system to take effect, HP-UX has the kctune command, while Solaris has the /etc/system configuration file.
Specifics for each Operating System:
The most up-to-date information on the limits can be found in the man page for "ulimit".
AIX®
Global settings are generally set in the file /etc/security/limits, although there can be different limit files for LPARs and WPARs.
The table does not represent all ulimit items as they can vary between operating system versions. For more information about this topic, see the ulimit man page or the limits file.
Command-Line limit_name*
|
/etc/security/limits
|
Description
|
ulimit -c [value] |
core
core_hard |
Core file size in 512 byte blocks. |
ulimit -d [value] (K bytes) |
data data_hard |
Data segment size of processes in kilobytes. |
ulimit -f [value] |
fsize fsize_hard |
File size limit in 512 byes blocks. |
ulimit -n [value] |
nofiles nofiles_hard |
Max number of open files or sockets per process. |
ulimit -m [value] (K bytes) |
rss rss_hard |
The memory size of the process in kilobytes. |
ulimit -r [value] |
threads threads_hard |
Max number of threads per process. |
ulimit -s [value] (K bytes) |
stack stack_hard |
The stack segment size in kilobytes. |
ulimit -t [value] (seconds) |
cpu cpu_hard |
Max per process CPU time (in seconds). |
ulimit -u [value] |
nproc nproc_hard |
Specifies the limit of the number of processes per user. |
HP-UX®
There is no editable file for global setting on HP-UX. Instead, you would need to issue the specific ulimit command in your shell's (or user's) profile configuration.
There are similar kernel settings you can also set with kctune, such as "maxfiles_lim", but these kernel parameters do not normally need to be changed. For more information about this topic, see the man page.
The table might not represent all ulimit items as they can vary between operating system versions. For more information about this topic, review the ulimit man page or the OS documentation.
Command "ulimit" limit_name*
|
Description
|
ulimit -c [value] |
Core file size in 512 byte blocks. |
ulimit -d [value] |
Data segment size of processes in 512 byte blocks. |
ulimit -f [value] |
File size limit in 512 byes blocks. |
ulimit -n [value] |
Max number of open files or sockets per process. |
ulimit -m [value] |
The memory size of the process in 512 byte blocks. |
ulimit -s [value] |
The stack segment size in 512 byte blocks. |
ulimit -t [value] (seconds) |
Max per process CPU time (in seconds). |
Linux®
Global settings are set in the file /etc/security/limits.conf.
The format for setting each limit is as follows:
- <domain> controls which users or groups has the limits
- <type> is either the string "soft" or "hard" limits.
- The hyphen "-" can also be used which represents both soft and hard limits
- <item> and <value> are shown in the table. Most values can also use the string unlimited.
The table does not represent all ulimit attributes, as they can vary between Linux variants. For more information about this topic, see the ulimit man page, or the limits.conf file.
Command-Line limit_name
|
/etc/security/limits.conf <item>
|
Description
|
ulimit -c [value] |
core |
Max core dump file size (KB) |
ulimit -d [value] |
data |
Max data size (KB) |
ulimit -f [value] |
fsize |
Max file size (KB) |
ulimit -l [value] |
memlock |
Max size of address space that can be locked into memory (KB) |
ulimit -n [value] |
nofile |
Max number of open files or sockets per process |
ulimit -u [value] |
nproc |
Max number of processes for a single user |
ulimit -m [value] |
rss |
Max resident set size (KB) |
ulimit -s [value] |
stack |
The maximum stack size (KB) |
ulimit -t [value] |
cpu |
Max CPU time (minutes or seconds) |
[Service]
LimitNOFILE=524288
LimitNPROC=131072
LimitCORE=infinity
LimitFSIZE=infinity
Update the global systemd defaults and update the default ulimit(s): https://www.kernel.org/doc/man-pages/online/pages/man5/systemd-system.conf.5.html
# mkdir -p /etc/systemd/system.conf.d/
# cat >/etc/systemd/system.conf.d/10-defaultulimits.conf <<EOF
[Manager]
DefaultLimitNOFILE=524288
DefaultLimitNPROC=131072
DefaultLimitCORE=infinity
DefaultLimitFSIZE=infinity
EOF
Solaris™
Solaris does not have a global settings file specifically for ulimits (however you can set kernel-wide settings in the "/etc/system" file). Instead, you would need to issue the specific ulimit command in your shell's (or user's) profile configuration (like .profile or .login).
Depending on the shell used, the ulimit command is slightly different. For more information about this topic, see the man page.
You can also set kernel-wide settings for various limits in the "/etc/system" file.
For example, "set lim_fd_max = [value]" is the global hard file descriptor limit, and "set rlim_fd_cur = [value]" is the global soft file descriptor limit. For more information about this topic, see the system OS's documentation for information on the /etc/system file.
The table does not represent all ulimit items as they can vary between operating system versions. For more information about this topic, see the ulimit man page or your OS documentation.
Command-Line limit_name *
(sh, ksh, bash) |
Command-Line
(csh) |
Description
|
ulimit -c [value] |
ulimit coredumpsize [value] (K bytes) |
Core file size in 512 byte blocks. |
ulimit -d [value] (K bytes) |
ulimit datasize [value] (K bytes) |
Data segment size of processes in kilobytes. |
ulimit -f [value] |
ulimit filesize [value] (K bytes) |
File size limit in 512 byes blocks. |
ulimit -n [value] |
ulimit descriptors [value] |
Max number of open files or sockets per process (plus 1) |
<
tt>ulimit -s [value] (K bytes) |
ulimit stacksize [value] (K bytes) |
The stack segment size in kilobytes. |
ulimit -t [value] (seconds) |
ulimit cputime [value] (seconds) |
Max per process CPU time (in seconds). |
ulimit -v [value] (K bytes) |
ulimit memorysize [value] (K bytes) |
Maximum size of virtual memory (in kilobytes) |
Yes, you can increase the number of file descriptors through the ulimit -n [value] command. These settings do not take effect until your application server (and node agent) are restarted; make sure the restart is on the same command-line session where "ulimit -n" was run.
However, if you increase the value high enough and still run into these errors, you might want to check for a file descriptor leak (meaning a leak of opened files or sockets in your application code). The command lsof can provide information on the quantity and types of file descriptors in use.
Further information can be found at this link: Too Many Open Files error message
Generally setting the ulimit to unlimited is allowed. However, if an attempt is made to set this ulimit to unlimited on the command line, an error is displayed indicating the operation is not permitted if unlimited is not allowed. Not all versions of Linux support the unlimited value, and in those cases, you might need to pick a valid positive integer to use. In the Information Center for WebSphere Application Server, there is a recommendation of 8000.
[root] # ulimit -n unlimited
bash: ulimit: open files: cannot modify limit: Operation not permitted
If you try to edit the /etc/security/limits.conf file to force the number of open files to unlimited, the setting is considered invalid and resets to 0. This action prevents any new processes from generating by that user or group. If the settings are for the root user, the system slowly becomes unusable as new processes are unable to generate. A recovery disc is needed to reset the value.
At startup, the operating system has yet to load specific user profiles, even for the root user. When you see individual services and processes, those processes are really child processes of the init process
This information was previously documented for AIX 6.1 in a IBM Docs article entitled "telinit or init Command", under the Environments section. Here's the quoted section:
"A command that is executed by init from the /etc/inittab file uses init's ulimit values and not the default values as given in /etc/security/limits. The result is that a command that is successfully executed from the command line may not execute correctly when invoked by init. Any command that has specific ulimit requirements should include specific actions to set the ulimit values as required."
Related Information
Was this topic helpful?
Document Information
Modified date:
18 November 2024
UID
swg21469413