sections in this module City College of San Francisco - CS260A
Linux System Administration

Module: Processes
module list

Process Limits

Preview question: Unix systems try to give each user as many resources as he or she needs to complete their work. Limitations on users can, however, be imposed by implementing quotas, or by the use of resource limits. The bash built-in ulimit provides a command-line interface to your current resource limits. Investigate ulimit to see what can be limited.

One of the philosophies of Unix is to give the user whatever they need. If a user process is greedy, it can gobble a lot of system resources. There are basic safeguards built into the system (priorities and reserved disk areas for system functions), but, unless limits are imposed on them, processes can consume everything on the system. This is one reason why disk partitions, system monitoring, and disk quotas are important.

Some limits can be imposed on processes by the ulimit or more recent prlimit commands, which set maximums for certain system resources for a user or for a process. In keeping with Unix' philosophy, the system limits (called the hard limits) are generous, to say the least. You can examine them with ulimit -Ha. Here are the results on hills, which is running RH6, and has ample system resources. Note the generous hard limits, even though this is a multi-user system. (The numbers are less on our SL7 host machines.)

$ ulimit -Ha
core file size          (blocks, -c) unlimited
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 192903
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 4096
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) unlimited
cpu time               (seconds, -t) unlimited
max user processes              (-u) 192903
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

As you see, most important limits, such as the maximum amount of file space or cpu time or memory usage, are unlimited.

There are two sets of limits: the hard limits, or the maximums, and the soft limits, or the current limits. Hard limits can never be increased, but they can be decreased. Soft limits can be increased up to the hard limit. Thus, to set a limit for user, the hard limit would be decreased before the user gets control of the login shell. Then the hard limit is set for that login session (and for all children). The user has control of their soft limit, which they may set if they so choose.

Each individual limit is identified by an option. The output of ulimit (above) shows the option for each limit. 


ulimit -Hc 10000

sets the hard limit of the core file size to 10000 (blocks).

ulimit -f 450000

sets both hard and soft limit of the max file size (of any one file!) to 450,000 blocks.

ulimit -Su

outputs the soft limit of the maximum number of processes that the user can run concurrently.

The system administrator sets process limits using the files in /etc/security: limits.conf and limits.d/*

Prev This page was made entirely with free software on linux:  
the Mozilla Project

Copyright 2015 Greg Boyd - All Rights Reserved.