LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-09-2017, 05:33 PM   #1
pinuxl7
LQ Newbie
 
Registered: Nov 2017
Posts: 1

Rep: Reputation: Disabled
Talking linux command 'nice'


Hello, so im learning about linux for the first time at university, in my question sheet it asked a few things about nice and renice but there were two questions about the nice command came up, they asked:

What would passing the priority 20 to nice do?
What would passing the priority -20 to nice do?

i thought you are unable to pass these as the limit is -20 and 19 respectively? please help as this is important for my work. Thank you.
 
Old 11-09-2017, 05:54 PM   #2
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,569

Rep: Reputation: 2129Reputation: 2129Reputation: 2129Reputation: 2129Reputation: 2129Reputation: 2129Reputation: 2129Reputation: 2129Reputation: 2129Reputation: 2129Reputation: 2129
If you're taking a course on Linux, shouldn't you at least have a Linux VM you can fire up and test things on? To answer your question, if you try to set it to 20 (or 30, or 40) it just caps it at 19.
 
1 members found this post helpful.
Old 11-09-2017, 10:57 PM   #3
Turbocapitalist
Senior Member
 
Registered: Apr 2005
Distribution: Ubuntu, Devuan, OpenBSD
Posts: 3,265
Blog Entries: 3

Rep: Reputation: 1442Reputation: 1442Reputation: 1442Reputation: 1442Reputation: 1442Reputation: 1442Reputation: 1442Reputation: 1442Reputation: 1442Reputation: 1442
Definitely get at least a VM with an easy distro like Linux Mint. Though much better would be to use it as you main OS for while on "bare metal" and run the legacy OS inside a VM on Linux Mint. That will really push you to get experience and that will give you an edge over others.

About your actual question, the distros all come with reference documentation built-in. These are called manual pages or "man pages" for short. They are found for every program though they do vary in quality. So there are also manual pages for nice or renice.

Code:
man nice
man renice
These are the reference manuals. If you want tutorials or guides, search the web. Or if you are stuck on a point try some experiments on your own and then ask here.
 
Old 11-10-2017, 07:55 AM   #4
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 3,588
Blog Entries: 1

Rep: Reputation: 778Reputation: 778Reputation: 778Reputation: 778Reputation: 778Reputation: 778Reputation: 778
+20 is a valid nice level, but linux runs those as 19, which is the lowest priority. Most things kernel run at -20, the highest priority. Most things user run at 0. Which can be problematic for gui things as X runs at 0. I tend to launch things under X from a terminal so I can (re)nice it to +10 so X remains responsive. Mostly the browser though so I can kill it when it's being bad without having to wait for X to get it's turn to use resources. It's just a number that's supposed to represent a priority. About the only time I see it make a difference is for slower things under load, like networking or storage. If you want dd to NOT interrupt your game play or media consumption, give it a lower priority. If you want your audio to not chirp and beep while povray renders an image sequence, give the audio a higher priority.

$ nice -n 10 iceweasel

$ sudo renice -n -5 jackdbus
 
Old 11-10-2017, 09:16 AM   #5
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,569

Rep: Reputation: 2129Reputation: 2129Reputation: 2129Reputation: 2129Reputation: 2129Reputation: 2129Reputation: 2129Reputation: 2129Reputation: 2129Reputation: 2129Reputation: 2129
Quote:
Originally Posted by Shadow_7 View Post
About the only time I see it make a difference is for slower things under load, like networking or storage. If you want dd to NOT interrupt your game play or media consumption, give it a lower priority.
FYI - for storage, it's more advantageous to use ionice instead of nice. Nice is really focused on CPU load, and while it does affect I/O, that's what ionice is built for. Give a big file copy/move an ionice level of 3 (idle) and it'll take just a hair longer than normal but you won't even feel it on the machine.

Last edited by suicidaleggroll; 11-10-2017 at 09:18 AM.
 
Old 11-10-2017, 10:22 AM   #6
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 9,078
Blog Entries: 4

Rep: Reputation: 3169Reputation: 3169Reputation: 3169Reputation: 3169Reputation: 3169Reputation: 3169Reputation: 3169Reputation: 3169Reputation: 3169Reputation: 3169Reputation: 3169
"niceness" is one of several parameters that are constantly being considered by the scheduler. It is intended to be your voluntary, subjective suggestion of how the process should be scheduled. For instance, a time-consuming background process owned by you, that you think really doesn't need to "be the center of attention," might be given a niceness value that might encourage the scheduler to consider other, simultaneous work in favor of it.

When an interactive (GUI) program uses background processes to help it do some of the work, that program might purposely add some "niceness" to those processes so that they are less likely to compete with the main program, which thereby might remain more-responsive to user input.

I use the word, "might," throughout this description ...

Last edited by sundialsvcs; 11-10-2017 at 10:24 AM.
 
Old 11-11-2017, 01:25 PM   #7
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,729

Rep: Reputation: 1286Reputation: 1286Reputation: 1286Reputation: 1286Reputation: 1286Reputation: 1286Reputation: 1286Reputation: 1286Reputation: 1286
And for those systems using systemd, nice barely has any effect.

This is mostly due to the cgroups setup that isolates each user from another, and from the system.

Nice priority values are only evaluated relative to the cgroup structure - and not the system as a whole.
 
Old 11-21-2017, 07:32 AM   #8
giis
Member
 
Registered: Nov 2013
Location: Third Rock from Moon
Distribution: RPM/DEB based and LFS
Posts: 73

Rep: Reputation: Disabled
If you find man nice or renice little too long - here is a shortcut install https://tldr.sh/ and check out the examples for nice and renice.
 
Old 11-21-2017, 09:37 AM   #9
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 9,078
Blog Entries: 4

Rep: Reputation: 3169Reputation: 3169Reputation: 3169Reputation: 3169Reputation: 3169Reputation: 3169Reputation: 3169Reputation: 3169Reputation: 3169Reputation: 3169Reputation: 3169
Generally speaking, any niceness that is different from the default will influence the scheduling algorithm as much as any particular value might do.

If you were running many things simultaneously and wanted to voluntarily rank those things (as, for example, an application might want to do, with regards to its own processes or threads ...), then simply set appropriate values relative to each other, and that will be sufficient.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Command line expansion nice-to-have CollieJim Linux - Software 1 03-15-2012 04:46 AM
'Nice' command not valid anymore? witek Linux - General 0 07-13-2011 12:58 AM
using nice(inc) command deathonator Programming 2 04-13-2008 03:04 PM
nice command what?? kkraju555 Linux - Software 2 05-22-2004 01:08 PM
Scheduling priority for the 'nice' command savoiu Linux - Newbie 2 05-18-2004 11:35 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:19 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration