1997-01-21 15:05:15 +00:00
|
|
|
.\" Copyright (c) 1996 David Nugent <davidn@blaze.net.au>
|
|
|
|
.\" All rights reserved.
|
|
|
|
.\"
|
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
.\" modification, is permitted provided that the following conditions
|
|
|
|
.\" are met:
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
.\" notice immediately at the beginning of the file, without modification,
|
|
|
|
.\" this list of conditions, and the following disclaimer.
|
|
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
|
|
.\" 3. This work was done expressly for inclusion into FreeBSD. Other use
|
|
|
|
.\" is permitted provided this notation is included.
|
|
|
|
.\" 4. Absolutely no warranty of function or purpose is made by the author
|
|
|
|
.\" David Nugent.
|
|
|
|
.\" 5. Modifications may be freely made to this file providing the above
|
|
|
|
.\" conditions are met.
|
|
|
|
.\"
|
1999-08-28 01:08:13 +00:00
|
|
|
.\" $FreeBSD$
|
1997-01-21 15:05:15 +00:00
|
|
|
.\"
|
|
|
|
.Dd January 15, 1996
|
|
|
|
.Dt LIMITS 1
|
2001-07-10 14:16:33 +00:00
|
|
|
.Os
|
1997-01-21 15:05:15 +00:00
|
|
|
.Sh NAME
|
|
|
|
.Nm limits
|
1997-07-21 12:06:18 +00:00
|
|
|
.Nd set or display process resource limits
|
1997-01-21 15:05:15 +00:00
|
|
|
.Sh SYNOPSIS
|
2000-11-20 19:21:22 +00:00
|
|
|
.Nm
|
1997-07-21 12:06:18 +00:00
|
|
|
.Op Fl C Ar class
|
1997-01-21 15:05:15 +00:00
|
|
|
.Op Fl SHB
|
1997-07-21 12:06:18 +00:00
|
|
|
.Op Fl ea
|
1997-01-21 15:05:15 +00:00
|
|
|
.Op Fl cdflmnstu Op val
|
2000-11-20 19:21:22 +00:00
|
|
|
.Nm
|
1997-07-21 12:06:18 +00:00
|
|
|
.Op Fl C Ar class
|
|
|
|
.Op Fl SHB
|
|
|
|
.Op Fl cdflmnstu Op val
|
|
|
|
.Op Fl E
|
2001-02-01 16:38:02 +00:00
|
|
|
.Op Ar name Ns = Ns Ar value ...
|
1997-07-21 12:06:18 +00:00
|
|
|
.Op Ar command
|
2000-11-20 19:21:22 +00:00
|
|
|
.Nm
|
1997-07-21 12:06:18 +00:00
|
|
|
.Op Fl U Ar user
|
|
|
|
.Op Fl SHB
|
|
|
|
.Op Fl ea
|
|
|
|
.Op Fl cdflmnstu Op val
|
2000-11-20 19:21:22 +00:00
|
|
|
.Nm
|
1997-07-21 12:06:18 +00:00
|
|
|
.Op Fl U Ar user
|
1997-01-21 15:05:15 +00:00
|
|
|
.Op Fl SHB
|
|
|
|
.Op Fl cdflmnstu Op val
|
|
|
|
.Op Fl E
|
2001-02-01 16:38:02 +00:00
|
|
|
.Op Ar name Ns = Ns Ar value ...
|
1997-01-21 15:05:15 +00:00
|
|
|
.Op Ar command
|
|
|
|
.Sh DESCRIPTION
|
|
|
|
.Nm Limits
|
1999-04-13 02:32:12 +00:00
|
|
|
either prints or sets kernel resource limits, and may optionally set
|
1997-01-21 15:05:15 +00:00
|
|
|
environment variables like
|
|
|
|
.Xr env 1
|
|
|
|
and run a program with the selected resources.
|
|
|
|
Three uses of the
|
2000-03-26 14:37:47 +00:00
|
|
|
.Nm
|
1997-01-21 15:05:15 +00:00
|
|
|
command are possible:
|
|
|
|
.Pp
|
2001-02-14 10:14:35 +00:00
|
|
|
.Bl -tag -width indent
|
|
|
|
.It Xo
|
|
|
|
.Nm
|
2000-11-20 19:21:22 +00:00
|
|
|
.Op Ar limitflags
|
2001-02-01 16:38:02 +00:00
|
|
|
.Op Ar name Ns = Ns Ar value
|
1997-01-21 15:05:15 +00:00
|
|
|
.Ar command
|
2001-02-14 10:14:35 +00:00
|
|
|
.Xc
|
1997-01-21 15:05:15 +00:00
|
|
|
This usage sets limits according to
|
|
|
|
.Ar limitflags ,
|
|
|
|
optionally sets environment variables given as
|
2001-02-01 16:38:02 +00:00
|
|
|
.Ar name Ns = Ns Ar value
|
1997-01-21 15:05:15 +00:00
|
|
|
pairs, and then runs the specified command.
|
2001-02-14 10:14:35 +00:00
|
|
|
.It Xo
|
|
|
|
.Nm
|
2000-11-20 19:21:22 +00:00
|
|
|
.Op Ar limitflags
|
2001-02-14 10:14:35 +00:00
|
|
|
.Xc
|
1997-01-21 15:05:15 +00:00
|
|
|
This usage determines values of resource settings according to
|
|
|
|
.Ar limitflags ,
|
|
|
|
does not attempt to set them and outputs these values to
|
|
|
|
standard output.
|
|
|
|
By default, this will output the current kernel resource settings
|
|
|
|
active for the calling process.
|
|
|
|
Using the
|
|
|
|
.Fl C Ar class
|
|
|
|
or
|
|
|
|
.Fl U Ar user
|
|
|
|
flags, you may also display the current resource settings modified
|
2001-06-24 01:34:38 +00:00
|
|
|
by the appropriate login class resource limit entries from
|
1997-01-21 15:05:15 +00:00
|
|
|
the
|
|
|
|
.Xr login.conf 5
|
|
|
|
login capabilities database.
|
2001-02-14 10:14:35 +00:00
|
|
|
.It Xo
|
|
|
|
.Nm
|
2000-11-20 19:21:22 +00:00
|
|
|
.Fl e Op Ar limitflags
|
2001-02-14 10:14:35 +00:00
|
|
|
.Xc
|
1997-01-21 15:05:15 +00:00
|
|
|
This usage determines values of resource settings according to
|
|
|
|
.Ar limitflags ,
|
|
|
|
but does not set them itself.
|
|
|
|
Like the previous usage it outputs these values to standard
|
|
|
|
output, except that it will emit them in
|
|
|
|
.Em eval
|
|
|
|
format, suitable for the calling shell.
|
|
|
|
The calling shell is determined by examining the entries in the
|
|
|
|
.Pa /proc
|
|
|
|
filesystem for the parent process.
|
2000-03-26 14:37:47 +00:00
|
|
|
If the shell is known (i.e. it is one of sh, csh, bash, tcsh, ksh,
|
1997-01-21 15:05:15 +00:00
|
|
|
pdksh or rc),
|
2000-03-26 14:37:47 +00:00
|
|
|
.Nm
|
1997-01-21 15:05:15 +00:00
|
|
|
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
|
2001-02-01 16:38:02 +00:00
|
|
|
.Xr sh 1
|
1997-01-21 15:05:15 +00:00
|
|
|
is used.
|
|
|
|
.Pp
|
|
|
|
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.
|
|
|
|
.Pp
|
|
|
|
Within a shell script,
|
2000-03-26 14:37:47 +00:00
|
|
|
.Nm
|
1997-01-21 15:05:15 +00:00
|
|
|
will normally be used with eval within backticks as follows:
|
|
|
|
.Pp
|
|
|
|
.Dl eval `limits -e -C daemon`
|
|
|
|
.Pp
|
|
|
|
which causes the output of
|
2000-03-26 14:37:47 +00:00
|
|
|
.Nm
|
1997-01-21 15:05:15 +00:00
|
|
|
to be evaluated and set by the current shell.
|
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
The value of limitflags specified in the above contains one or more of the
|
|
|
|
following options:
|
|
|
|
.Pp
|
|
|
|
.Bl -tag -width "-d [limit]"
|
|
|
|
.It Fl C Ar class
|
|
|
|
Use current resource values, modified by the resource entries applicable
|
|
|
|
for the login class "class".
|
|
|
|
.It Fl U Ar user
|
|
|
|
Use current resource values, modified by the resource entries applicable
|
|
|
|
to the login class which "user" belongs to.
|
|
|
|
If the user does not belong to a class, then the resource capabilities
|
|
|
|
for the "default" class are used, if it exists, or the "root" class if
|
|
|
|
the user is a superuser account.
|
|
|
|
.It Fl S
|
2000-03-26 14:37:47 +00:00
|
|
|
Select display or setting of "soft" (or current) resource limits.
|
1997-01-21 15:05:15 +00:00
|
|
|
If specific limits settings follow this switch, only soft limits are
|
|
|
|
affected unless overridden later with either the
|
|
|
|
.Fl H
|
|
|
|
or
|
|
|
|
.Fl B
|
|
|
|
flags.
|
|
|
|
.It Fl H
|
2000-03-26 14:37:47 +00:00
|
|
|
Select display or setting of "hard" (or maximum) resource limits.
|
1997-01-21 15:05:15 +00:00
|
|
|
If specific limits settings follow this switch, only hard limits are
|
|
|
|
affected until overridden later with either the
|
|
|
|
.Fl S
|
|
|
|
or
|
|
|
|
.Fl B
|
|
|
|
flags.
|
|
|
|
.It Fl B
|
2000-03-26 14:37:47 +00:00
|
|
|
Select display or setting of both "soft" (current) or "hard" (maximum)
|
1997-01-21 15:05:15 +00:00
|
|
|
resource limits.
|
|
|
|
If specific limits settings follow this switch, both soft and hard
|
|
|
|
limits are affected until overridden later with either the
|
|
|
|
.Fl S
|
|
|
|
or
|
|
|
|
.Fl H
|
|
|
|
flags.
|
|
|
|
.Fl e
|
2000-03-26 14:37:47 +00:00
|
|
|
Select "eval mode" formatting for output.
|
1997-01-21 15:05:15 +00:00
|
|
|
This is valid only on display mode and cannot be used when running a
|
|
|
|
command.
|
1998-06-04 21:06:07 +00:00
|
|
|
The exact syntax used for output depends upon the type of shell from
|
1997-01-21 15:05:15 +00:00
|
|
|
which
|
2000-03-26 14:37:47 +00:00
|
|
|
.Nm
|
1997-01-21 15:05:15 +00:00
|
|
|
is invoked.
|
1999-10-09 20:47:59 +00:00
|
|
|
.It Fl b Op Ar limit
|
|
|
|
Selects or sets the
|
|
|
|
.Em sbsize
|
|
|
|
resource limit.
|
1997-01-21 15:05:15 +00:00
|
|
|
.It Fl c Op Ar limit
|
2000-03-26 14:37:47 +00:00
|
|
|
Select or set (if 'limit' is specified) the
|
1997-07-16 11:35:18 +00:00
|
|
|
.Em coredumpsize
|
1997-01-21 15:05:15 +00:00
|
|
|
resource limit.
|
|
|
|
A value of 0 disables core dumps.
|
|
|
|
.It Fl d Op Ar limit
|
2000-03-26 14:37:47 +00:00
|
|
|
Select or set (if 'limit' is specified) the
|
1997-01-21 15:05:15 +00:00
|
|
|
.Em datasize
|
|
|
|
resource limit.
|
|
|
|
.It Fl f Op Ar limit
|
2000-03-26 14:37:47 +00:00
|
|
|
Select or set the
|
1997-01-21 15:05:15 +00:00
|
|
|
.Em filesize
|
|
|
|
resource limit.
|
|
|
|
.It Fl l Op Ar limit
|
2000-03-26 14:37:47 +00:00
|
|
|
Select or set the
|
1997-01-21 15:05:15 +00:00
|
|
|
.Em memorylocked
|
|
|
|
resource limit.
|
|
|
|
.It Fl m Op Ar limit
|
2000-03-26 14:37:47 +00:00
|
|
|
Select or set the
|
1997-01-21 15:05:15 +00:00
|
|
|
.Em memoryuse
|
1997-07-21 12:06:18 +00:00
|
|
|
size limit.
|
1997-01-21 15:05:15 +00:00
|
|
|
.It Fl n Op Ar limit
|
2000-03-26 14:37:47 +00:00
|
|
|
Select or set the
|
1997-01-21 15:05:15 +00:00
|
|
|
.Em openfiles
|
1999-03-15 15:36:56 +00:00
|
|
|
resource limit. The system-wide limit on the maximum number of
|
|
|
|
open files per process can be viewed using the 'sysctl kern.maxfilesperproc'
|
|
|
|
command. The total number of simultaneously open files in the entire
|
|
|
|
system is limited to the value displayed by the 'sysctl kern.maxfiles'
|
|
|
|
command.
|
1997-01-21 15:05:15 +00:00
|
|
|
.It Fl s Op Ar limit
|
2000-03-26 14:37:47 +00:00
|
|
|
Select or set the
|
1997-01-21 15:05:15 +00:00
|
|
|
.Em stacksize
|
|
|
|
resource limit.
|
|
|
|
.It Fl t Op Ar limit
|
2000-03-26 14:37:47 +00:00
|
|
|
Select or set the
|
1997-01-21 15:05:15 +00:00
|
|
|
.Em cputime
|
|
|
|
resource limit.
|
|
|
|
.It Fl u Op Ar limit
|
2000-03-26 14:37:47 +00:00
|
|
|
Select or set the
|
1997-01-21 15:05:15 +00:00
|
|
|
.Em maxproc
|
1999-03-15 15:36:56 +00:00
|
|
|
resource limit. The system-wide limit on the maximum number of processes
|
|
|
|
allowed per UID can be viewed using the 'sysctl kern.maxprocperuid' command.
|
|
|
|
The maximum number of processes that can be running simultaneously
|
|
|
|
in the entire system is limited to the value given by
|
|
|
|
the 'sysctl kern.maxproc' command.
|
1997-01-21 15:05:15 +00:00
|
|
|
.Pp
|
2000-03-26 14:37:47 +00:00
|
|
|
Valid values for
|
|
|
|
.Ar limit
|
|
|
|
in the above set of flags consist of either the
|
|
|
|
string
|
|
|
|
.Em infinity ,
|
|
|
|
.Em inf ,
|
|
|
|
.Em unlimited
|
|
|
|
or
|
|
|
|
.Em unlimit
|
|
|
|
for an infinite (or kernel-defined maximum)
|
1997-01-21 15:05:15 +00:00
|
|
|
limit, or a numeric value maybe 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:
|
|
|
|
.Pp
|
|
|
|
.Bl -tag -offset indent -width "xxxx" -compact
|
|
|
|
.It b
|
|
|
|
512 byte blocks.
|
|
|
|
.It k
|
|
|
|
kilobytes (1024 bytes).
|
|
|
|
.It m
|
|
|
|
megabytes (1024*1024 bytes).
|
|
|
|
.It g
|
|
|
|
gigabytes.
|
|
|
|
.It t
|
1998-06-04 21:06:07 +00:00
|
|
|
terabytes.
|
1997-01-21 15:05:15 +00:00
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Em 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:
|
|
|
|
.Bl -tag -offset indent -width "xxxx" -compact
|
|
|
|
.It s
|
|
|
|
seconds.
|
|
|
|
.It m
|
|
|
|
minutes.
|
|
|
|
.It h
|
|
|
|
hours.
|
|
|
|
.It d
|
|
|
|
days.
|
|
|
|
.It w
|
|
|
|
weeks.
|
|
|
|
.It y
|
|
|
|
365 day years.
|
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
.It Fl E
|
|
|
|
The option
|
|
|
|
.Sq Fl E
|
|
|
|
causes
|
2000-03-26 14:37:47 +00:00
|
|
|
.Nm
|
1997-01-21 15:05:15 +00:00
|
|
|
to completely ignore the environment it inherits.
|
|
|
|
.It Fl a
|
|
|
|
This option forces all resource settings to be displayed even if
|
|
|
|
other specific resource settings have been specified.
|
|
|
|
For example, if you wish to disable core dumps when starting up
|
|
|
|
the usenet news system, but wish to set all other resource settings
|
|
|
|
as well that apply to the 'news' account, you might use:
|
|
|
|
.Pp
|
|
|
|
.Dl eval `limits -U news -aBec 0`
|
|
|
|
.Pp
|
|
|
|
As with the
|
1999-08-14 06:39:48 +00:00
|
|
|
.Xr setrlimit 2
|
1997-01-21 15:05:15 +00:00
|
|
|
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
|
2000-03-26 14:37:47 +00:00
|
|
|
.Nm
|
1997-01-21 15:05:15 +00:00
|
|
|
to raise a hard limit is considered a fatal error.
|
|
|
|
.El
|
|
|
|
.Sh DIAGNOSTICS
|
|
|
|
.Nm Limits
|
2000-03-26 14:37:47 +00:00
|
|
|
exits with EXIT_FAILURE if usage is incorrect in any way; i.e. an invalid
|
1997-01-21 15:05:15 +00:00
|
|
|
option, or set/display options are selected in the same invocation,
|
|
|
|
.Fl e
|
|
|
|
is used when running a program, etc.
|
|
|
|
When run in display or eval mode,
|
2000-03-26 14:37:47 +00:00
|
|
|
.Nm
|
1999-02-12 02:12:08 +00:00
|
|
|
exits with a status of EXIT_SUCCESS.
|
1997-01-21 15:05:15 +00:00
|
|
|
When run in command mode and execution of the command succeeds, the exit status
|
|
|
|
will be whatever the executed program returns.
|
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr csh 1 ,
|
|
|
|
.Xr env 1 ,
|
|
|
|
.Xr limit 1 ,
|
|
|
|
.Xr sh 1 ,
|
1998-05-08 14:46:23 +00:00
|
|
|
.Xr getrlimit 2 ,
|
|
|
|
.Xr setrlimit 2 ,
|
1997-01-21 15:05:15 +00:00
|
|
|
.Xr login_cap 3 ,
|
1999-03-15 15:36:56 +00:00
|
|
|
.Xr login.conf 5 ,
|
|
|
|
.Xr sysctl 8
|
1997-01-21 15:05:15 +00:00
|
|
|
.Sh BUGS
|
|
|
|
.Nm Limits
|
|
|
|
does not handle commands with equal (``='') signs in their
|
|
|
|
names, for obvious reasons.
|
|
|
|
.Pp
|
2000-03-26 14:37:47 +00:00
|
|
|
When eval output is selected, the
|
|
|
|
.Pa /proc
|
|
|
|
filesystem must be installed
|
1997-01-21 15:05:15 +00:00
|
|
|
and mounted for the shell to be correctly determined, and therefore
|
|
|
|
output syntax correct for the running shell.
|
2000-03-26 14:37:47 +00:00
|
|
|
The default output is valid for
|
2001-02-01 16:38:02 +00:00
|
|
|
.Xr sh 1 ,
|
2000-03-26 14:37:47 +00:00
|
|
|
so this means that any
|
1997-01-21 15:05:15 +00:00
|
|
|
usage of
|
2000-03-26 14:37:47 +00:00
|
|
|
.Nm
|
|
|
|
in eval mode prior mounting
|
|
|
|
.Pa /proc
|
|
|
|
may only occur in standard bourne
|
1997-01-21 15:05:15 +00:00
|
|
|
shell scripts.
|
|
|
|
.Pp
|
|
|
|
.Nm Limits
|
|
|
|
makes no effort to ensure that resource settings emitted or displayed
|
|
|
|
are valid and settable by the current user.
|
1997-07-16 11:35:18 +00:00
|
|
|
Only a superuser account may raise hard limits, and when doing so
|
2000-03-26 14:37:47 +00:00
|
|
|
the
|
|
|
|
.Fx
|
|
|
|
kernel will silently lower limits to values less than
|
1997-01-21 15:05:15 +00:00
|
|
|
specified if the values given are too high.
|