Name
nice — stdin stdout - file -- opt --help --version
Synopsis
nice [-nlevel
]command_line
When invoking a system-intensive program, you can be nice to the
other processes (and users) by lowering its priority. That’s what the
nice
command is for: it sets a
nice level (an amount of “niceness”) for a
process so it gets less attention from the OS X process
scheduler.[19] Here’s an example of setting a big job to run at nice
level 7:
➜ nice −n 7 sort VeryLargeFile > outfile
If you run nice
without a
level, 10 is used. Normal processes (run without nice
) run at level zero. The superuser can
also lower the nice level, increasing a process’s priority:
➜ sudo nice -n -10 myprogram
To see the nice
levels of
your jobs, use ps
and look at the
“NI” column:
➜ ps -o pid,user,args,nice
[19] This is called “nicing” the process. You’ll hear the term used as a verb: “That process was niced to 12.”
Get Macintosh Terminal Pocket Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.