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 processif 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 processandrenice 5 processdo 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
pscommand. 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 suitablenice'' 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-sodoku4.- Change the niceness of the process.
renice 7 39565.- 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-sodoku4.- 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 39563956 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
- 175 LFX Mentorship
- 175 LFX Mentorship: Linux Kernel
- 745 Linux Foundation IT Professional Programs
- 372 Cloud Engineer IT Professional Program
- 168 Advanced Cloud Engineer IT Professional Program
- 73 DevOps IT Professional Program - Discontinued
- 3 DevOps & GitOps IT Professional Program
- 98 Cloud Native Developer IT Professional Program
- 7.6K Training Courses & Learning Paths
- AI & ML Training
- Blockchain & Decentralized Identity Training
- 1 Cloud & Containers Training
- Cybersecurity Training
- DevOps & Site-Reliability Training
- Linux Kernel Development Training
- Networking Training
- Open Source Best Practice Training
- System Administration Training
- System Engineering Training
- Web & Application Development Training
- 2 LFD103-JP クラス フォーラム
- 4 LFD210-CN Class Forum
- 764 LFD259 Class Forum
- 681 LFS101 Class Forum
- 2 LFS158-JP クラス フォーラム
- 162 LFS207 Class Forum
- 3 LFS207-DE-Klassenforum
- 4 LFS207-JP クラス フォーラム
- 61 LFS241 Class Forum
- 52 LFS242 Class Forum
- 42 LFS243 Class Forum
- 19 LFS244 Class Forum
- 4 LFS250-JP クラス フォーラム
- 166 LFS253 Class Forum
- 1.4K LFS258 Class Forum
- 792 Hardware
- 202 Drivers
- 68 I/O Devices
- 37 Monitors
- 95 Multimedia
- 173 Networking
- 91 Printers & Scanners
- 87 Storage
- 768 Linux Distributions
- 81 Debian
- 67 Fedora
- 22 Linux Mint
- 13 Mageia
- 24 openSUSE
- 150 Red Hat Enterprise
- 31 Slackware
- 13 SUSE Enterprise
- 356 Ubuntu
- 465 Linux System Administration
- 31 Cloud Computing
- 73 Command Line/Scripting
- Github systems admin projects
- 98 Linux Security
- 78 Network Management
- 101 System Management
- 46 Web Management
- 106 Mobile Computing
- 18 Android
- 73 Development
- 1.2K New to Linux
- 1K Getting Started with Linux
- 392 Off Topic
- 121 Introductions
- 181 Small Talk
- 29 Study Material
- 945 Programming and Development
- 310 Kernel Development
- 617 Software Development
- 977 Software
- 369 Applications
- 182 Command Line
- 5 Compiling/Installing
- 68 Games
- 317 Installation
- Archived
- 2 LFD140 Class 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)
