LIMITS(1) | MidnightBSD General Commands Manual | LIMITS(1) |
limits
— set or
display process resource limits
limits |
[-C class |
-P pid |
-U user]
[-SHB ] [-ea ]
[-bcdfklmnopstuvw
[val]] |
limits |
[-C class |
-U user]
[-SHB ] [-bcdfklmnopstuvw
[val]] [-E ]
[[name=value ...]
command] |
The limits
utility either prints or sets
kernel resource limits, and may optionally set environment variables like
env(1) and run a program
with the selected resources. Three uses of the
limits
utility are possible:
limits
[limitflags]
[name=value ...]
commandlimits
[limitflags]-C
class or
-U
user options, you may
also display the current resource settings modified by the appropriate
login class resource limit entries from the
login.conf(5) login
capabilities database.limits
-e
[limitflags]eval
format, suitable for the calling
shell. If the shell is known (i.e., it is one of
sh
, csh
,
bash
, tcsh
,
ksh
, pdksh
or
rc
), limits
emits
limit
or ulimit
commands
in the format understood by that shell. If the name of the shell cannot be
determined, then the ulimit
format used by
sh(1) is used.
This is very useful for setting limits used by scripts, or prior launching of daemons and other background tasks with specific resource limit settings, and provides the benefit of allowing global configuration of maximum resource usage by maintaining a central database of settings in the login class database.
Within a shell script, limits
will
normally be used with eval within backticks as follows:
eval `limits -e -C
daemon`
which causes the output of limits
to
be evaluated and set by the current shell.
The value of limitflags specified in the above contains one or more of the following options:
-C
class-U
userdefault
” class are used, if it
exists, or the “root
” class if the
user is a superuser account.-P
pid-S
-H
or -B
options.-H
-S
or -B
options.-B
-S
or
-H
options.-e
limits
is invoked.-b
[val]-c
[val]-d
[val]-f
[val]-k
[val]-l
[val]-m
[val]-n
[val]-o
[val]-p
[val]-s
[val]-t
[val]-u
[val]-v
[val]-w
[val]Valid values for val in the above set of
options consist of either the string
“infinity
”,
“inf
”,
“unlimited
” or
“unlimit
” for an infinite (or
kernel-defined maximum) limit, or a numeric value optionally followed by a
suffix. Values which relate to size default to a value in bytes, or one of
the following suffixes may be used as a multiplier:
The cputime resource defaults to a number of seconds, but a multiplier may be used, and as with size values, multiple values separated by a valid suffix are added together:
-E
limits
to completely ignore the environment
it inherits.-a
news
” account, you might use:
eval `limits -U news -aBec
0`
As with the
setrlimit(2) call,
only the superuser may raise process “hard” resource
limits. Non-root users may, however, lower them or change
“soft” resource limits within to any value below the hard
limit. When invoked to execute a program, the failure of
limits
to raise a hard limit is considered a
fatal error.
The limits
utility exits with
EXIT_FAILURE
if usage is incorrect in any way; i.e.,
an invalid option, or set/display options are selected in the same
invocation, -e
is used when running a program, etc.
When run in display or eval mode, limits
exits with
a status of EXIT_SUCCESS
. When run in command mode
and execution of the command succeeds, the exit status will be whatever the
executed program returns.
csh(1), env(1), limit(1), sh(1), getrlimit(2), setrlimit(2), login_cap(3), login.conf(5), rctl(8), sysctl(8)
The limits
utility first appeared in
FreeBSD 2.1.7.
The limits
utility was written by
David Nugent
<davidn@FreeBSD.org>.
The limits
utility does not handle
commands with equal (‘=
’) signs in
their names, for obvious reasons.
The limits
utility makes no effort to
ensure that resource settings emitted or displayed are valid and settable by
the current user. Only a superuser account may raise hard limits, and when
doing so the FreeBSD kernel will silently lower
limits to values less than specified if the values given are too high.
May 26, 2020 | midnightbsd-3.1 |