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
- 60 LFX Mentorship
- 113 LFX Mentorship: Linux Kernel
- 618 Linux Foundation IT Professional Programs
- 321 Cloud Engineer IT Professional Program
- 142 Advanced Cloud Engineer IT Professional Program
- 55 DevOps Engineer IT Professional Program
- 68 Cloud Native Developer IT Professional Program
- 6 Express Training Courses
- 6 Express Courses - Discussion Forum
- 2.3K Training Courses
- 19 LFC110 Class Forum - Discontinued
- 9 LFC131 Class Forum
- 31 LFD102 Class Forum
- 174 LFD103 Class Forum
- 22 LFD121 Class Forum
- 2 LFD137 Class Forum
- 61 LFD201 Class Forum
- 2 LFD210 Class Forum
- 1 LFD210-CN Class Forum
- 1 LFD213 Class Forum - Discontinued
- 128 LFD232 Class Forum - Discontinued
- LFD237 Class Forum
- 23 LFD254 Class Forum
- 653 LFD259 Class Forum
- 108 LFD272 Class Forum
- 1 LFD272-JP クラス フォーラム
- 4 LFD273 Class Forum
- 2 LFS145 Class Forum
- 28 LFS200 Class Forum
- 740 LFS201 Class Forum - Discontinued
- 1 LFS201-JP クラス フォーラム
- 12 LFS203 Class Forum
- 92 LFS207 Class Forum
- 301 LFS211 Class Forum
- 54 LFS216 Class Forum
- 47 LFS241 Class Forum
- 41 LFS242 Class Forum
- 37 LFS243 Class Forum
- 12 LFS244 Class Forum
- 41 LFS250 Class Forum
- 1 LFS250-JP クラス フォーラム
- LFS251 Class Forum
- 142 LFS253 Class Forum
- LFS254 Class Forum
- LFS255 Class Forum
- LFS256 Class Forum
- LFS257 Class Forum
- 1.2K LFS258 Class Forum
- 10 LFS258-JP クラス フォーラム
- 106 LFS260 Class Forum
- 145 LFS261 Class Forum
- 39 LFS262 Class Forum
- 83 LFS263 Class Forum - Discontinued
- 15 LFS264 Class Forum - Discontinued
- 11 LFS266 Class Forum - Discontinued
- 20 LFS267 Class Forum
- 18 LFS268 Class Forum
- 26 LFS269 Class Forum
- 204 LFS272 Class Forum
- 1 LFS272-JP クラス フォーラム
- LFS274 Class Forum
- 3 LFS281 Class Forum
- 249 LFW211 Class Forum
- 177 LFW212 Class Forum
- 9 SKF100 Class Forum
- SKF200 Class Forum
- 907 Hardware
- 220 Drivers
- 74 I/O Devices
- 44 Monitors
- 116 Multimedia
- 210 Networking
- 102 Printers & Scanners
- 86 Storage
- 764 Linux Distributions
- 88 Debian
- 66 Fedora
- 15 Linux Mint
- 13 Mageia
- 24 openSUSE
- 143 Red Hat Enterprise
- 33 Slackware
- 13 SUSE Enterprise
- 357 Ubuntu
- 482 Linux System Administration
- 40 Cloud Computing
- 70 Command Line/Scripting
- Github systems admin projects
- 95 Linux Security
- 80 Network Management
- 108 System Management
- 51 Web Management
- 71 Mobile Computing
- 24 Android
- 32 Development
- 1.2K New to Linux
- 1.1K Getting Started with Linux
- 545 Off Topic
- 132 Introductions
- 223 Small Talk
- 22 Study Material
- 831 Programming and Development
- 282 Kernel Development
- 515 Software Development
- 974 Software
- 260 Applications
- 185 Command Line
- 3 Compiling/Installing
- 119 Games
- 318 Installation
- 65 All In Program
- 65 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)