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
- 49 LFX Mentorship
- 102 LFX Mentorship: Linux Kernel
- 550 Linux Foundation Boot Camps
- 294 Cloud Engineer Boot Camp
- 118 Advanced Cloud Engineer Boot Camp
- 52 DevOps Engineer Boot Camp
- 53 Cloud Native Developer Boot Camp
- 4 Express Training Courses
- 4 Express Courses - Discussion Forum
- 1.9K Training Courses
- 18 LFC110 Class Forum
- 6 LFC131 Class Forum
- 24 LFD102 Class Forum
- 150 LFD103 Class Forum
- 17 LFD121 Class Forum
- 61 LFD201 Class Forum
- LFD210 Class Forum
- LFD210-CN Class Forum
- 1 LFD213 Class Forum - Discontinued
- 128 LFD232 Class Forum
- LFD237 Class Forum
- 23 LFD254 Class Forum
- 596 LFD259 Class Forum
- 102 LFD272 Class Forum
- 1 LFD272-JP クラス フォーラム
- LFD273 Class Forum
- 2 LFS145 Class Forum
- 24 LFS200 Class Forum
- 739 LFS201 Class Forum
- 1 LFS201-JP クラス フォーラム
- 3 LFS203 Class Forum
- 69 LFS207 Class Forum
- 300 LFS211 Class Forum
- 54 LFS216 Class Forum
- 47 LFS241 Class Forum
- 41 LFS242 Class Forum
- 37 LFS243 Class Forum
- 11 LFS244 Class Forum
- 33 LFS250 Class Forum
- 1 LFS250-JP クラス フォーラム
- LFS251 Class Forum
- 139 LFS253 Class Forum
- 1K LFS258 Class Forum
- 10 LFS258-JP クラス フォーラム
- 92 LFS260 Class Forum
- 129 LFS261 Class Forum
- 32 LFS262 Class Forum
- 79 LFS263 Class Forum
- 15 LFS264 Class Forum
- 11 LFS266 Class Forum
- 17 LFS267 Class Forum
- 17 LFS268 Class Forum
- 23 LFS269 Class Forum
- 203 LFS272 Class Forum
- 1 LFS272-JP クラス フォーラム
- LFS281 Class Forum
- 220 LFW211 Class Forum
- 166 LFW212 Class Forum
- SKF100 Class Forum
- 901 Hardware
- 219 Drivers
- 74 I/O Devices
- 44 Monitors
- 115 Multimedia
- 208 Networking
- 101 Printers & Scanners
- 85 Storage
- 761 Linux Distributions
- 88 Debian
- 66 Fedora
- 15 Linux Mint
- 13 Mageia
- 24 openSUSE
- 141 Red Hat Enterprise
- 33 Slackware
- 13 SUSE Enterprise
- 356 Ubuntu
- 476 Linux System Administration
- 41 Cloud Computing
- 69 Command Line/Scripting
- Github systems admin projects
- 94 Linux Security
- 77 Network Management
- 108 System Management
- 49 Web Management
- 66 Mobile Computing
- 23 Android
- 29 Development
- 1.2K New to Linux
- 1.1K Getting Started with Linux
- 536 Off Topic
- 131 Introductions
- 216 Small Talk
- 21 Study Material
- 816 Programming and Development
- 275 Kernel Development
- 507 Software Development
- 927 Software
- 260 Applications
- 183 Command Line
- 3 Compiling/Installing
- 76 Games
- 316 Installation
- 59 All In Program
- 59 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)