Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Nice (Unix)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Computer utility for Unix-like operating systems}} {{Redirect|Renice|the Polish village|Renice, Poland}} {{refimprove|date=November 2010}} {{lowercase|title=nice (Unix)}} {{Infobox software | name = nice | logo = | screenshot = | screenshot size = | caption = | developer = [[Bell Labs|AT&T Bell Laboratories]] | released = {{Start date and age|1973|11}} | latest release version = | latest release date = | operating system = [[Unix]] and [[Unix-like]] | platform = [[Cross-platform]] | genre = [[Command (computing)|Command]] | license = [[coreutils]]: [[GNU General Public License#Version 3|GNU GPL v3]] [[4.4BSD]]: [[BSD licenses#4-clause license (original "BSD License")|BSD License]] | website = }} <code>'''nice'''</code> is a program found on [[Unix]] and [[Unix-like]] [[operating system]]s such as [[Linux]]. It directly maps to a [[Kernel (operating system)|kernel]] [[system call|call]] of the same name. <code>nice</code> is used to invoke a [[List of Unix commands|utility]] or [[shell script]] with a particular [[scheduling (computing)|CPU priority]], thus giving the [[Process (computing)|process]] more or less CPU time than other processes. A niceness of -20 is the lowest niceness, or highest priority. The default niceness for processes is inherited from its parent process and is usually 0. Systems have diverged on what priority is the lowest. Linux systems document a niceness of 19 as the lowest priority,<ref name="linuxrenice">{{man|1|renice|ManKier}}</ref> BSD systems document 20 as the lowest priority.<ref>{{cite web |url=https://man.netbsd.org/renice.8|title=renice(8) - NetBSD Man Pages |date=October 22, 2020 |website=NetBSD |access-date=April 18, 2023}}</ref> In both cases, the "lowest" priority is documented as running only when nothing else wants to. ==Etymology== ''Niceness value'' is a number attached to processes in *nix systems, that is used along with other data (such as the amount of [[input/output|I/O]] done by each process) by the kernel process scheduler to calculate a process' 'true priority'{{emdash}}which is used to decide how much CPU time is allocated to it. The program's name, <em>nice</em>, 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 power{{emdash}}freeing 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.<ref>Jerry Peek, Shelley Powers, Tim O'Reilly and Mike Loukides (2002). ''Unix Power Tools''. O'Reilly, p. 507.</ref> ==Use and effect== <code>nice</code> becomes useful when several processes are demanding more resources than the [[Central processing unit|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 <code>/etc/security/limits.conf</code> to allow other users or groups to set low nice values.<ref>{{man|5|limits.conf|ManKier}}</ref> If a user wanted to compress a large file without slowing down other processes, they might run the following: <syntaxhighlight lang="console"> $ nice -n 19 tar cvzf archive.tgz largefile </syntaxhighlight> The exact mathematical effect of setting a particular niceness value for a process depends on the details of how the [[Scheduling (computing)|scheduler]] 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 <code>nice +15</code>, will receive 25% of the CPU time allocated to a normal-priority process: (20 β 15)/(20 β 0) = 0.25.<ref>{{cite book |title=Operating system concepts |last1=Silberschatz |first1=Abraham |last2=Galvin |first2=Peter B. |last3=Gagne |first3=Greg |date=2013 |publisher=Wiley |location=Hoboken, N.J |isbn=978-1-118-06333-0 |page=294 |edition=ninth}}</ref> On the [[Berkeley Software Distribution|BSD]] 4.x scheduler, on the other hand, the ratio in the same example is about ten to one.{{Citation needed|date=November 2013}} ==Similar commands== The related <code>'''renice'''</code> program can be used to change the priority of a process that is already running.<ref name="linuxrenice"/> Linux also has an <code>'''ionice'''</code> program, which affects scheduling of I/O rather than CPU time.<ref>{{man|1|ionice|ManKier}}</ref> ==See also== * [[kill (command)|kill]] * [[ps (Unix)|ps]] * [[top (software)|top]] * ''ionice'' from [[util-linux]] (see manual for disk storage I/O priorities) ==References== {{Reflist}} ==External links== {{Wikibooks|Guide to Unix|Commands}} * {{man|cu|nice|SUS|invoke a utility with an altered nice value}} {{Unix commands}} {{Core Utilities commands}} [[Category:Unix SUS2008 utilities]] [[Category:Unix process- and task-management-related software]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:Citation needed
(
edit
)
Template:Cite book
(
edit
)
Template:Cite web
(
edit
)
Template:Core Utilities commands
(
edit
)
Template:Emdash
(
edit
)
Template:Infobox software
(
edit
)
Template:Lowercase
(
edit
)
Template:Man
(
edit
)
Template:Redirect
(
edit
)
Template:Refimprove
(
edit
)
Template:Reflist
(
edit
)
Template:Short description
(
edit
)
Template:Sister project
(
edit
)
Template:Unix commands
(
edit
)
Template:Wikibooks
(
edit
)