How do I set per-process limits?

How do I set per-process limits? Added: 09/13/01


Many system-wide per-process limits can be set by root by modifying
kernel
parameters. Regular users can also set some per-process limits via shell
builtins. Of course, system-wide limits cannot be exceeded.

In the POSIX and Korn shells, the 'ulimit' builtin command can be used to
set pre-process limits. Though both builtins have the name ulimit, their
capabilities and syntax are different.

For the Korn shell (ksh), ulimit only affects the filesize limit, which
defaults to 4194303, which ksh interprets to mean unlimited. See ksh(1).

For the POSIX shell (sh), there are several variables that can be set
with ulimit. The 'ulimit -a' command lists all the variables that can be
set. There are soft and hard limits for these variables, and some ulimit
maximum values are based on certain kernel parameters:

Soft Limit Relevant Kernel Params
========================================================
$ ulimit -aS
time(seconds) unlimited
file(blocks) unlimited
data(kbytes) 65536 max determined by maxdsiz
stack(kbytes) 8192 max determined by maxssiz
memory(kbytes) unlimited
coredump(blocks) 4194303
nofiles(descriptors) 60 max determined by maxfiles

Hard Limit Relevant Kernel Params
========================================================
$ ulimit -aH
time(seconds) unlimited
file(blocks) unlimited
data(kbytes) 65536
stack(kbytes) 8192
memory(kbytes) unlimited
coredump(blocks) unlimited
nofiles(descriptors) 1024 max determined by maxfiles_lim

See also sh-posix(1).

The C shell (csh) has similar variables. These variables can be set
using
the csh 'limit' builtin command. See csh(1).



Home
FAQ