confusion about renice command
Hi,
Does the renice +number command increase the niceness to "number" unit or set the niceness to that "number" ?
For instance, I can't use the commandrenice +5 process
if that process have a nice value set to 10, unless I usesudo
. Because this command is going set the nice value to 5 and thus decrease the old value rather than increasing it!On my machine
renice +5 process
andrenice 5 process
do the same. Is that normal ? what's the difference between the two commands ?Increasing the niceness is supposed to decrease the priority (and vice-versa when decreasing). However, when the niceness is increased we see the priority increased as well in the PRI column of the
ps
command. What does the PRI column show exactly ?
Thanks.
Comments
-
Hi,
Does the renice +number command increase the niceness to "number"
unit or set the niceness to that "number" ?Set.
For instance, I can't use the command renice +5 process if that process
have a nice value set to 10, unless I use sudo. Because this command is
going set the nice value to 5 and thus decrease the old value rather than
increasing it!I didn't understand the details of your test, but if you are increasing the priority of a process, you need to be root or use sudo. You can see that in man renice(1):
NOTES
Users other than the superuser may only alter the priority of processes they own. Furthermore, an unprivi‐
leged user can only increase thenice value'' (i.e., choose a lower priority) and such changes are irre‐ versible unless (since Linux 2.6.12) the user has a suitable
nice'' resource limit (see ulimit(1) and getr‐
limit(2)).The superuser may alter the priority of any process and set the priority to any value in the range -20 to 19. Useful priorities are: 19 (the affected processes will run only when nothing else in the system wants to), 0 (the ``base'' scheduling priority), anything negative (to make things go very fast).
On my machine renice +5 process and renice 5 process do the same.
Is that normal ? what's the difference between the two commands ?That happens because the niceness of a process (started by you) starts on 0. So, if you add 5 or set to 5, the result will be the same. To help understand how it works, you can use the following:
1.- Start a process, say gnome-clocks.
2.- Print basic information of the processes and look at gnome-clocks (or whatever you are testing with):
ps -eo pid,tid,ni,pri,stat,comm3.- See that "NI" and "PRI" indicates for the process.
4.- Change the niceness of the process.
5.- Print the information again, and compare. Ask yourself: what happened with the niceness and priority value when adding 7, for example?Regards,
Luis.0 -
Hello,
I think there was confusion on Question 2.3. The two commands (renice 5 and renice +5 works on the same manner). I tried the following:frank@debian:~$ nice -n -7 sleep 3000 &
[1] 4528frank@debian:~$ nice -n -7 sleep 3000 &
[2] 4529frank@debian:~$ renice +5 4528
4528 (process ID) old priority -7, new priority 5frank@debian:~$ renice 5 4529
4529 (process ID) old priority -7, new priority 5frank@debian:~$ ps -lf
F S UID PID PPID C PRI NI ADDR SZ WCHAN STIME TTY TIME CMD
0 S frank 3189 3036 0 80 0 - 2217 - 09:23 pts/1 00:00:00 bash
0 S frank 4528 3189 0 85 5 - 1315 hrtime 10:17 pts/1 00:00:00 sleep 3000
0 S frank 4529 3189 0 85 5 - 1315 hrtime 10:17 pts/1 00:00:00 sleep 3000
0 R frank 4532 3189 0 80 0 - 2658 - 10:17 pts/1 00:00:00 ps -lfThe new priority for the reniced process is the same: 85.
Regards,
Francesco1 -
you are correct. The argument to "renice" is the nice value to set to, not the increment or decrement. The text is somewhat ambiguous as it explains properly in once place and screws up in the earlier place. this will be fixed in the next update due in a month or two at the most. Thanks!
BTW, your example has to be run as root, at least on my workstation, because only root can set the niceness to -7
3 -
Hello Coop,
it’s a pleasure to view your replay. Only for completion, I executed the command as user frank such as I set the permission for nice for that user in the configuration file /etc/security/limits.conf
Thanks again
1 -
Nice to see someone pay attention to details like /etc/security/limits.conf. you would be surprised how many things can slip by. I suspect the error in the renice description has been there literally for years and noone has tagged us on it before as best I can remember, as we fix these things as we notice them!
1 -
Hi,
Thanks for the answers.
Please, let's me explain with the following scenario1.- Start a process, say gnome-clocks.
started sudoku
2.- Print basic information of the processes and look at gnome-clocks (or whatever you are testing with):
ps -eo pid,tid,ni,pri,stat,comm3956 3956 0 19 SL+ gnome-sodoku
4.- Change the niceness of the process.
renice 7 3956
5.- Print the information again, and compare. Ask yourself: what happened with the niceness and priority value when adding 7, for example?
3956 3956 7 12 SL+ gnome-sodoku
4.- Change the niceness of the process. AGAIN
renice +2 3956
This is supposed to turn the niceness to 9 (7+2) and the priority to 10 but it fails (permission denied)Moreover,
renice +9 3956
3956 3956 9 10 SL+ gnome-sodoku
This instruction sets the niceness to 9 rather than 16 (7+9)
How is this explained ?Regards.
0 -
as explained in the posts, please read more carefully. renice sets it to the value given, not as an increment. That's exactly what this thread was about so you are getting the correct behaviour (if I am understanding correctly!)
2 -
Just to add my two cents to what Coop already said, you always can see the man command. As in this case, man renice(1) says the following:
DESCRIPTION
renice alters the scheduling priority of one or more running processes. The first argument is the priority value to be used. The other arguments are interpreted as process IDs (by default), process group IDs, user IDs, or user names. renice'ing a process group causes all processes in the process group to have their scheduling priority altered. renice'ing a user causes all processes owned by the user to have their scheduling priority altered.Note the following ==> The first argument is the priority value to be used.
Regards,
Luis.0 -
Thanks for your answers.
I'm sorry, I didn't see the posts from coop and francesco.iennarella before my second post.
It is clearer now.The confusion came from the Question 3.2 of the course.
Which command will increase the niceness by 5 units of the process with PID = 444?
replacing "increase" with "set" would be better.
1 -
We will have to look at this, I don't have the KC in front of me.
Note this is a confusing issue, which is why the course material had it twisted up slightly
1 -
Hello,
Just to remind that the question 3.2 still waits the correction:
Question 3.2
Which command will increase the niceness by 5 units of the process with PID = 444?Incorrect Answer
A. renice 5 444Correct Answer
B. renice +5 444Your Answer
C. nice -5 444
D. nice +5 444Next QuestionBR
C0 -
This error should have been fixed months ago but seems to have fallen through the cracks. It should say "set " not "increase". It will be fixed in next update.
1
Categories
- All Categories
- 167 LFX Mentorship
- 219 LFX Mentorship: Linux Kernel
- 795 Linux Foundation IT Professional Programs
- 355 Cloud Engineer IT Professional Program
- 179 Advanced Cloud Engineer IT Professional Program
- 82 DevOps Engineer IT Professional Program
- 127 Cloud Native Developer IT Professional Program
- 112 Express Training Courses
- 112 Express Courses - Discussion Forum
- 6.2K Training Courses
- 48 LFC110 Class Forum - Discontinued
- 17 LFC131 Class Forum
- 35 LFD102 Class Forum
- 227 LFD103 Class Forum
- 14 LFD110 Class Forum
- 39 LFD121 Class Forum
- 15 LFD133 Class Forum
- 7 LFD134 Class Forum
- 17 LFD137 Class Forum
- 63 LFD201 Class Forum
- 3 LFD210 Class Forum
- 5 LFD210-CN Class Forum
- 2 LFD213 Class Forum - Discontinued
- 128 LFD232 Class Forum - Discontinued
- 1 LFD233 Class Forum
- 2 LFD237 Class Forum
- 23 LFD254 Class Forum
- 697 LFD259 Class Forum
- 109 LFD272 Class Forum
- 3 LFD272-JP クラス フォーラム
- 10 LFD273 Class Forum
- 152 LFS101 Class Forum
- 1 LFS111 Class Forum
- 1 LFS112 Class Forum
- 1 LFS116 Class Forum
- 1 LFS118 Class Forum
- LFS120 Class Forum
- 7 LFS142 Class Forum
- 7 LFS144 Class Forum
- 3 LFS145 Class Forum
- 1 LFS146 Class Forum
- 3 LFS147 Class Forum
- 1 LFS148 Class Forum
- 15 LFS151 Class Forum
- 1 LFS157 Class Forum
- 33 LFS158 Class Forum
- 8 LFS162 Class Forum
- 1 LFS166 Class Forum
- 1 LFS167 Class Forum
- 3 LFS170 Class Forum
- 2 LFS171 Class Forum
- 1 LFS178 Class Forum
- 1 LFS180 Class Forum
- 1 LFS182 Class Forum
- 1 LFS183 Class Forum
- 29 LFS200 Class Forum
- 736 LFS201 Class Forum - Discontinued
- 2 LFS201-JP クラス フォーラム
- 14 LFS203 Class Forum
- 102 LFS207 Class Forum
- 1 LFS207-DE-Klassenforum
- 1 LFS207-JP クラス フォーラム
- 301 LFS211 Class Forum
- 55 LFS216 Class Forum
- 48 LFS241 Class Forum
- 42 LFS242 Class Forum
- 37 LFS243 Class Forum
- 15 LFS244 Class Forum
- LFS245 Class Forum
- LFS246 Class Forum
- 50 LFS250 Class Forum
- 1 LFS250-JP クラス フォーラム
- LFS251 Class Forum
- 154 LFS253 Class Forum
- LFS254 Class Forum
- LFS255 Class Forum
- 5 LFS256 Class Forum
- 1 LFS257 Class Forum
- 1.3K LFS258 Class Forum
- 10 LFS258-JP クラス フォーラム
- 111 LFS260 Class Forum
- 159 LFS261 Class Forum
- 41 LFS262 Class Forum
- 82 LFS263 Class Forum - Discontinued
- 15 LFS264 Class Forum - Discontinued
- 11 LFS266 Class Forum - Discontinued
- 20 LFS267 Class Forum
- 24 LFS268 Class Forum
- 29 LFS269 Class Forum
- 1 LFS270 Class Forum
- 199 LFS272 Class Forum
- 1 LFS272-JP クラス フォーラム
- LFS274 Class Forum
- 3 LFS281 Class Forum
- 9 LFW111 Class Forum
- 260 LFW211 Class Forum
- 182 LFW212 Class Forum
- 13 SKF100 Class Forum
- 1 SKF200 Class Forum
- 1 SKF201 Class Forum
- 782 Hardware
- 198 Drivers
- 68 I/O Devices
- 37 Monitors
- 96 Multimedia
- 174 Networking
- 91 Printers & Scanners
- 83 Storage
- 743 Linux Distributions
- 80 Debian
- 67 Fedora
- 15 Linux Mint
- 13 Mageia
- 23 openSUSE
- 143 Red Hat Enterprise
- 31 Slackware
- 13 SUSE Enterprise
- 348 Ubuntu
- 461 Linux System Administration
- 39 Cloud Computing
- 70 Command Line/Scripting
- Github systems admin projects
- 90 Linux Security
- 77 Network Management
- 101 System Management
- 46 Web Management
- 64 Mobile Computing
- 17 Android
- 34 Development
- 1.2K New to Linux
- 1K Getting Started with Linux
- 371 Off Topic
- 114 Introductions
- 174 Small Talk
- 19 Study Material
- 507 Programming and Development
- 285 Kernel Development
- 204 Software Development
- 1.8K Software
- 211 Applications
- 180 Command Line
- 3 Compiling/Installing
- 405 Games
- 309 Installation
- 97 All In Program
- 97 All In Forum
Upcoming Training
-
August 20, 2018
Kubernetes Administration (LFS458)
-
August 20, 2018
Linux System Administration (LFS301)
-
August 27, 2018
Open Source Virtualization (LFS462)
-
August 27, 2018
Linux Kernel Debugging and Security (LFD440)