$linuxjunkies
>

prlimit(1)

Get and set process resource limits.

UbuntuDebianFedoraArch

Synopsis

prlimit [OPTION]... [--PID pid] [LIMIT=value...]

Description

Display or modify resource limits for a process. Resource limits control the maximum amount of system resources (CPU time, memory, file size, etc.) that a process can use. Without arguments, shows all limits for the current process or specified PID.

Changes apply to the specified process and its children. Use with a command to execute a process under new limits.

Common options

FlagWhat it does
--pid PIDGet/set limits for the specified process ID instead of current shell
--cpu=LIMITSet CPU time limit in seconds
--nofile=LIMITSet maximum number of open file descriptors
--nproc=LIMITSet maximum number of processes user can create
--as=LIMITSet virtual memory (address space) limit in bytes
--memlock=LIMITSet maximum locked memory in bytes
--msgqueue=LIMITSet maximum message queue size in bytes
-v, --verboseShow resource limit names and values in human-readable format
-o LISTSpecify output columns to display

Examples

Display all resource limits for the current process

prlimit

Show all limits for process with PID 1234

prlimit --pid 1234

Start a new bash shell with maximum 1024 open file descriptors

prlimit --nofile=1024 bash

Limit CPU time to 60 seconds for process 5678

prlimit --cpu=60 --pid 5678

Run a program with 1 GB virtual memory limit

prlimit --as=1G ./memory_intensive_program

Display all limits for PID 1234 in verbose human-readable format

prlimit -v --pid 1234

Execute Python script with max 256 processes and 4096 file descriptors

prlimit --nproc=256 --nofile=4096 python script.py

Remove CPU time limit for process 1234

prlimit --pid 1234 --cpu=unlimited

Related commands