Ulimit

From NovaOrdis Knowledge Base
Jump to navigation Jump to search

Internal

Overview

Provides control over the resources available to the shell and to processes started by it, on systems that allow such control. The -H and -S options specify that the hard or soft limit is set for the given resource. A hard limit cannot be increased by a non-root user once it is set; a soft limit may be increased up to the value of the hard limit. If neither -H nor -S is specified, both the soft and hard limits are set. The value of limit can be a number in the unit specified for the resource or one of the special values hard, soft, or unlimited, which stand for the current hard limit, the current soft limit, and no limit, respectively. If limit is omitted, the current value of the soft limit of the resource is printed, unless the -H option is given. When more than one resource is specified, the limit name and unit are printed before the value.

The hard limit is the upper bound of the property, set by root. The soft limit is the per-user limit that can be adjusted at run time (using ulimit) up to the hard limit.

These limits can be set up permanently in /etc/security/limits.conf specifically for the account we want:

jbossusr soft nofile 16384
jbossusr hard nofile 16384

Options

  • -a All current limits are reported
  • -b The maximum socket buffer size
  • -c The maximum size of core files created
  • -d The maximum size of a process' data segment
  • -e The maximum scheduling priority ("nice")
  • -f The maximum size of files written by the shell and its children
  • -i The maximum number of pending signals
  • -l The maximum size that may be locked into memory
  • -m The maximum resident set size (many systems do not honor this limit)
  • -n The maximum number of open file descriptors (most systems do not allow this value to be set)
  • -p The pipe size in 512-byte blocks (this may not be set)
  • -q The maximum number of bytes in POSIX message queues
  • -r The maximum real-time scheduling priority
  • -s The maximum stack size
  • -t The maximum amount of cpu time in seconds
  • -u The maximum number of processes available to a single user
  • -v The maximum amount of virtual memory available to the shell
  • -x The maximum number of file locks
  • -T The maximum number of threads

To Get a Hard Limit for the Value


     ulimit -Hn

!!!To Set A Value

!!.bashrc

Edit the corresponding .bashrc and add the following (for example, for file descriptors) but make sure it's under the hard limit set by root:

{{{

   ulimit -n 2048

}}}

!!/etc/security/limits.conf


{{{ jbossusr soft nofile 16384 jbossusr hard nofile 16384 }}}


This change does not require a reboot - only that all processes belonging to the user are killed and restarted, so they can use the new value.

Note that configuration files in /etc/security/limits.d directory, which are read in alphabetical order, override the settings in this file in case the domain is the same or more specific.

A good practice would be to modify those files first.

For example, the file that controls noproc and overrides /etc/security/limits.conf is /etc/security/limits.d/90-nproc.conf

{{{

  • soft nproc 1024

root soft nproc unlimited

}}}

__Referenced by:__\\ [{INSERT com.ecyrd.jspwiki.plugin.ReferringPagesPlugin WHERE max=20, maxwidth=50}]