HOME

TheInfoList



OR:

nice is a program found on
Unix Unix (; trademarked as UNIX) is a family of multitasking, multiuser computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, an ...
and
Unix-like A Unix-like (sometimes referred to as UN*X or *nix) operating system is one that behaves in a manner similar to a Unix system, although not necessarily conforming to or being certified to any version of the Single UNIX Specification. A Unix-li ...
operating system An operating system (OS) is system software that manages computer hardware, software resources, and provides common services for computer programs. Time-sharing operating systems schedule tasks for efficient use of the system and may also i ...
s such as
Linux Linux ( or ) is a family of open-source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically packaged as a Linux distribution, w ...
. It directly maps to a
kernel Kernel may refer to: Computing * Kernel (operating system), the central component of most operating systems * Kernel (image processing), a matrix used for image convolution * Compute kernel, in GPGPU programming * Kernel method, in machine learn ...
call Call or Calls may refer to: Arts, entertainment, and media Games * Call, a type of betting in poker * Call, in the game of contract bridge, a bid, pass, double, or redouble in the bidding stage Music and dance * Call (band), from Lahore, Paki ...
of the same name. nice is used to invoke a
utility As a topic of economics, utility is used to model worth or value. Its usage has evolved significantly over time. The term was introduced initially as a measure of pleasure or happiness as part of the theory of utilitarianism by moral philosoph ...
or shell script with a particular CPU priority, thus giving the
process A process is a series or set of activities that interact to produce a result; it may occur once-only or be recurrent or periodic. Things called a process include: Business and management *Business process, activities that produce a specific se ...
more or less CPU time than other processes. A niceness of -20 is the highest priority and 19 is the lowest priority. The default niceness for processes is inherited from its parent process and is usually 0.


Etymology

''Niceness value'' is a number attached to processes in *nix systems, that is used along with other data (such as the amount of I/O done by each process) by the kernel process scheduler to calculate a process' 'true priority'which is used to decide how much CPU time is allocated to it. The program's name, nice, is an allusion to its task of modifying a process' niceness value. The term ''niceness'' itself originates from the idea that a process with a higher niceness value is ''nicer'' to other processes in the system and to users by virtue of demanding less CPU powerfreeing up processing time and power for the more demanding programs, who would in this case be less ''nice'' to the system from a CPU usage perspective.


Use and effect

nice becomes useful when several processes are demanding more resources than the CPU can provide. In this state, a higher-priority process will get a larger chunk of the CPU time than a lower-priority process. Only the superuser (root) may set the niceness to a lower value (i.e. a higher priority). On Linux it is possible to change /etc/security/limits.conf to allow other users or groups to set low nice values. If a user wanted to compress a large file without slowing down other processes, they might run the following: $ nice -n 19 tar cvzf archive.tgz largefile The exact mathematical effect of setting a particular niceness value for a process depends on the details of how the
scheduler A schedule or a timetable, as a basic time-management tool, consists of a list of times at which possible tasks, events, or actions are intended to take place, or of a sequence of events in the chronological order in which such things are i ...
is designed on that implementation of Unix. A particular operating system's scheduler will also have various heuristics built into it (e.g. to favor processes that are mostly I/O-bound over processes that are CPU-bound). As a simple example, when two otherwise identical CPU-bound processes are running simultaneously on a single-CPU Linux system, each one's share of the CPU time will be proportional to 20 − ''p'', where ''p'' is the process' priority. Thus a process, run with nice +15, will receive 25% of the CPU time allocated to a normal-priority process: (20 − 15)/(20 − 0) = 0.25. On the BSD 4.x scheduler, on the other hand, the ratio in the same example is about ten to one.


Similar commands

The related renice program can be used to change the priority of a process that is already running. Linux also has an ionice program, which affects scheduling of I/O rather than CPU time.


See also

*
kill Kill often refers to: *Homicide, one human killing another *cause death, to kill a living organism, to cause its death Kill may also refer to: Media *'' Kill!'', a 1968 film directed by Kihachi Okamoto * ''Kill'' (Cannibal Corpse album), 2006 * ...
* ps * top * ''ionice'' from
util-linux is a standard package distributed by the Linux Kernel Organization for use as part of the Linux operating system. A fork, (with meaning "next generation"), was created when development stalled, but has been renamed back to , and is the offi ...
(see manual for disk storage I/O priorities)


References


External links

* {{Core Utilities commands Unix SUS2008 utilities Unix process- and task-management-related software