How To Set Linux Process Priority Using Nice and Renice Commands
How To Set Linux Process Priority Using Nice and Renice Commands
How To Set Linux Process Priority Using Nice and Renice Commands
Process Priority
51 Useful Lesser Known Commands for Linux Users
https://www.tecmint.com/set-linux-process-priority-using-nice-and-renice-commands/ 1/19
3/9/2019 How to Set Linux Process Priority Using nice and renice Commands
SPONSORED SEARCHES
Download Your Free eBooks NOW - 10 Free Vi/Vim Editor BEGINNER'S GUIDE
Linux eBooks for Administrators | 4 Free Shell Learn vi/vim as a Full Text Editor
Scripting eBooks
How to Check
Nice Value of
Linux Processes
To see the nice values of
processes, we can use
utilities such as ps, top or
htop.
$ ps -eo pid,ppid,ni,co
$ top
$ htop
Top Command
Htop Command
Difference Between
PR or PRI and NI
From the top and htop
outputs above, you’ll notice
that there is a column called
PR and PRI receptively
which show the priority of a
process.
How To Calculate PR
or PRI Values
51 Useful Lesser Known Commands for Linux Users
https://www.tecmint.com/set-linux-process-priority-using-nice-and-renice-commands/ 6/19
3/9/2019 How to Set Linux Process Priority Using nice and renice Commands
PR = 20 + NI
PR = 20 + (-20 to + 19)
PR = 20 + -20 to 20 +
PR = 0 to 39 which is s
Linux rt Process
How to Run A
Command with a
Given Nice Value
in Linux
Here, we will look at how to
prioritize the CPU usage of a
program or command. 51 Useful Lesser Known Commands for Linux Users
If you
https://www.tecmint.com/set-linux-process-priority-using-nice-and-renice-commands/ 7/19
3/9/2019 How to Set Linux Process Priority Using nice and renice Commands
$ nice -n niceness-valu
OR
$ nice -niceness-value
OR
$ nice --adjustment=nic
Important:
If no value is provided,
nice sets a priority of 10
by default.
A command or program
run without nice
defaults to a priority of
zero.
Only root can run a
command or program
with increased or high
priority.
Normal users can only
run a command or
program with low
priority.
Change the
Scheduling
Priority of a
Process in Linux
As we mentioned before,
Linux allows dynamic
priority-based scheduling.
Therefore, if a program is
already running, you can
change its priority with the
renice command in this
form:
51 Useful Lesser Known Commands for Linux Users
https://www.tecmint.com/set-linux-process-priority-using-nice-and-renice-commands/ 9/19
3/9/2019 How to Set Linux Process Priority Using nice and renice Commands
$ renice -n -12 -p 10
$ renice -n -2 -u apac
PR for ts3server = 20 +
PR for apache processes
How To Set
Default Nice
Value Of a
Speci c User’s
Processes
You can set the default nice
value of a particular user or
group in the
/etc/security/limits.conf
le. It’s primary function is
to de ne the resource limits
for the users logged in via
PAM.
<username> <hard|soft>
Alternatively, create a le
under
/etc/security/limits.d/
which overrides settings in
the main le above, and
these les are read in
alphabetical order.
# vi /etc/security/limi
$ man nice
$ man renice
If You Appreciate
What We Do Here On
TecMint, You Should
Consider:
1. Stay Connected to: Twitter |
Facebook | Google Plus
format.
6. Support us by taking our
online Linux courses
4
Swatchdog
– Simple
Log File
Watcher in
Real-Time
in Linux
1 AUG, 2018
4
How to
Monitor
Nginx
Performanc
e Using
Netdata on
CentOS 7
22 JUN, 2018
32
How To
Install
Elasticsear
ch,
Logstash,
and Kibana
(ELK Stack)
on
CentOS/RH
EL 7 51 Useful Lesser Known Commands for Linux Users
https://www.tecmint.com/set-linux-process-priority-using-nice-and-renice-commands/ 17/19
3/9/2019 How to Set Linux Process Priority Using nice and renice Commands
6 SEP, 2016
Comment
Name * Email *
Website
Post Comment
How to Use ‘fsck’ to Repair 10 Useful ‘Interview 10 Best Free and Open
File System Errors in Linux Questions and Answers’ on Source Software (FOSS)
Linux Shell Scripting Programs I Found in 2016
ngrep – A Network Packet
Analyzer for Linux 10 Useful “Squid Proxy 9 Best Tools to Access
Server” Interview Questions Remote Linux Desktop
How to Install ‘atop’ to and Answers in Linux
Monitor Logging Activity of 9 Tools to Monitor Linux
Linux System Processes 10 Useful Interview Disk Partitions and Usage in
Questions and Answers on Linux
Iotop – Monitor Linux Disk Linux Commands
I/O Activity and Usage Per- 8 Best Screen Recorders for
Process Basis 10 Basic Interview Desktop Screen Recording
Questions and Answers on in Linux
screenFetch – An Ultimate Linux Networking – Part 1
System Information 6 Best PDF Page Cropping
Generator for Linux 10 Interview Questions and Tools For Linux
Answers on Various
Commands in Linux
Tecmint: Linux Howtos, Tutorials & Guides © 2019.
All Rights Reserved.
The material in this site cannot be republished
either online or o ine, without our permission.