Run the nice command to change CPU dispatching priorities.
Changing dispatching priorities
Overview of nice
Dispatching priorities are controlled with the UNIX nice command.
The nice command lets you run a command at a lower than normal priority.
Displaying nice values
The nice values for tasks can be seen by using the –l option with the UNIX ps command.
ps – elf|sort + [column number] | [head] 0
When you enter ps –elf, the nice value will be an eight column table.
The result displays the top priority tasks on the database server, those with the smallest nice values. Nice values will range from 0, for top priority, to 39 for the lowest priority. View the code below to see the critical parts of this data.
View Dispatching Priorities
You must have root user authority to run a command at a higher priority. You can, however, lower the values of Oracle tasks with nice without root user authority.
There may be time when you want to lower the default dispatching priority. For example, a long-running batch task, one that runs more than 30
minutes, can be given a lower priority so that online transactions will get faster service.
The following command submits myprog.ksh in the background with a high nice value, thereby making it run more slowly and consume CPU resources only when other tasks do not require CPU.
nohup nice –n 25 myprog.ksh &
The nice command only works at the time that a task is started, and you cannot dynamically change the nice value.
If you want to change the priority of a task that is already executing, you can use the renice command.
If you have root user authority, you can alter the priority of any process and set the priority to any value in the range -20 to 20. The specified
increment changes the priority of a process in the following ways: Increment values
1 to 20--Runs the specified processes slower than the base priority
0--Sets the priority of the specified processes to the base scheduling
-20 to –1--Runs the specified processes quicker than the base priority
For example, assume that Oracle process ID (PIDs) 445 and 6678 are consuming too many resources:
Now, take another look at the dispatching priority:
We now see that it has dropped to priority 25, meaning that it will execute more slowly than other Oracle tasks that have a nice value of
20. The next lesson wraps up this module.