Manage an application's priority in Linux
In the land of Linux applications have what is called their "nice" value. This value sets the priority that any given application receives. The nice value ranges from -20 to 19. The lower the number the higher the priority. The higher the priority the the more CPU time a program will get. This comes in handy, say if you are rendering a video that is going to take a long time and can consume a good amount of your CPU cycles. You can set the nice value to give that process a lower priority so it won't consume that much of your CPU. The job will take longer, but you won't notice the huge hit on your processor. But how is this done? Let's take a look at how you can manage the priority of an application.
"nice" and "renice"
We'll start this with the command line method of changing these values (I'll demonstrate the GUI method in a moment). There are two commands you need to know: nice and renice. You use nice to launch a command with a specific nice value. You use renice when you want to change the priority of a program that is already running. Let's see how those commands are used.
In order to launch an application with a specific nice value you would issue the command:
nice APPLICATION NICE_VALUE
Where APPLICATION is the command used to launch the application and NICE_VALUE is the priority (from -20 to 20) that you want to launch the application with.
Now, to change the nice value of an application already running you would use the renice command like so (NOTE: If you are wanting to renice a service or an application that was started with administrative privileges you must have administrative privileges to run renice, so you'll need to either su to root or use sudo):
renice NICE_VALUE APPLICATION_PID
Where NICE_VALUE is the new nice value you want to assign to a process and APPLICATION_PID is the process ID of the application. NOTE: You can't renice with an application name like you can with nice.
Using a GUI
There is, of course, a much easier way of handling this task. If you open up the System Monitor you will notice a Nice column (see Figure 1). If you select an application and right-click it you will notice the Change Priority entry in the menu. Select that and a new window will appear with a slider allowing you to change the nice value from -20 to 20. Once you have changed that value click the Change Priority button and the new nice value is set.
You will probably notice that the majority of applications nice value is set to 0. That is normal priority. You will only want to change this value for certain circumstances - such as a run-away application or when an application will consume a good amount of CPU cycles. Other than that, Linux does a fairly good job managing the priority of the applications both the system and the users run. But it's always nice to know you can step in when necessary.Advertisement