System information
28 System Analysis and Tuning Guide
2.3.7 Modify a process' niceness: nice
and renice
The kernel determines which processes require more CPU time than others by the
process' nice level, also called niceness. The higher the “nice” level of a process is, the
less CPU time it will take from other processes. Nice levels range from -20 (the least
“nice” level) to 19. Negative values can only be set by root.
Adjusting the niceness level is useful when running a non time-critical process that
lasts long and uses large amounts of CPU time, such as compiling a kernel on a sys-
tem that also performs other tasks. Making such a process “nicer”, ensures that the
other tasks, for example a Web server, will have a higher priority.
Calling nice without any parameters prints the current niceness:
tux@mercury:~> nice
0
Running nice command increments the current nice level for the given command
by 10. Using nice -n level command lets you specify a new niceness relative
to the current one.
To change the niceness of a running process, use renice priority -p
process id, for example:
renice +5 3266
To renice all processes owned by a specific user, use the option -u user. Process
groups are reniced by the option -g process group id.
2.4 Memory
2.4.1 Memory Usage: free
The utility free examines RAM and swap usage. Details of both free and used mem-
ory and swap areas are shown:
tux@mercury:~> free
total used free shared buffers cached
Mem: 2062844 2047444 15400 0 129580 921936
-/+ buffers/cache: 995928 1066916