prlimit

The prlimit tool shows the soft & hard limits that apply to a process:

marc:~> prlimit ­-p 2569
RESOURCE    DESCRIPTION                            SOFT      HARD UNITS
AS          address space limit               unlimited unlimited bytes
CORE        max core file size                        0 unlimited blocks
CPU         CPU time                          unlimited unlimited seconds
DATA        max data size                     unlimited unlimited bytes
FSIZE       max file size                     unlimited unlimited blocks
LOCKS       max number of file locks held     unlimited unlimited
MEMLOCK     max locked­in­memory address space      65536     65536 bytes
MSGQUEUE    max bytes in POSIX mqueues           819200    819200 bytes
NICE        max nice prio allowed to raise            0         0
NOFILE      max number of open files               1024      4096
NPROC       max number of processes                4096     62905
RSS         max resident set size             unlimited unlimited pages
RTPRIO      max real­time priority                     0         0
RTTIME      timeout for real­time tasks        unlimited unlimited microsecs
SIGPENDING  max number of pending signals         62905     62905
STACK       max stack size                      8388608 unlimited bytes

If we need a more parsable output to feed to some script we can use –raw:

marc:~> prlimit –­­raw ­-p 32738
RESOURCE DESCRIPTION SOFT HARD UNITS
AS addressx20spacex20limit unlimited unlimited bytes
CORE maxx20corex20filex20size 0 unlimited blocks
CPU CPUx20time unlimited unlimited seconds
DATA maxx20datax20size unlimited unlimited bytes
FSIZE maxx20filex20size unlimited unlimited blocks
LOCKS maxx20numberx20ofx20filex20locksx20held unlimited unlimited
MEMLOCK maxx20locked­in­memoryx20addressx20space 65536 65536 bytes
MSGQUEUE maxx20bytesx20inx20POSIXx20mqueues 819200 819200 bytes
NICE maxx20nicex20priox20allowedx20tox20raise 0 0
NOFILE maxx20numberx20ofx20openx20files 1024 4096
NPROC maxx20numberx20ofx20processes 62905 62905
RSS maxx20residentx20setx20size unlimited unlimited pages
RTPRIO maxx20real­timex20priority 0 0
RTTIME timeoutx20forx20real­timex20tasks unlimited unlimited microsecs
SIGPENDING maxx20numberx20ofx20pendingx20signals 62905 62905
STACK maxx20stackx20size 8388608 unlimited bytes

If we are interested in just a few parameters we can list them …

root:~> prlimit ­­–rss ­­–fsize ­-p 32738
RESOURCE  DESCRIPTION                  SOFT      HARD UNITS
RSS       max resident set size   unlimited unlimited pages
FSIZE     max file size           unlimited unlimited blocks

If we want to chop the headings …

root:~> prlimit –­­noheadings ­­–rss –­­fsize -­p 32738
RSS       max resident set size   unlimited unlimited pages
FSIZE     max file size           unlimited unlimited blocks

We can also change limits by specifying the limit, hard and soft limits as in the examples below:

root:~> prlimit –­­nofile=1024:4096 ­-p 32738      → set soft & hard limit
root:~> prlimit ­­–msgqueue=:1000000 ­-p 29221     → set only hard limit
root:~> prlimit –­nproc=2048: ­-p 29221           → set only soft limit
root:~> prlimit –sigpending=8192 ­-p 29221       → set both to the same value
root:~> prlimit ­­–rss ­­–locks=4096 -­p 29221      → set locks limit and query rss
root:~> prlimit –rss=unlimited -­p 29221         → remove limits for rss

 

<< pidstat                     pmap >>