home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 39.10 A nice Gotcha Chapter 39
Time and Performance
Next: 39.12 What Makes Your Computer Slow? How Do You Fix It?
 

39.11 Changing a Job's Priority Under BSD UNIX

Once a job is running, you can use the renice (8) command to change the job's priority:

% /etc/renice 

priority 

-p 

pid


% /etc/renice 

priority 

-g 

pgrp


% /etc/renice 

priority 

-u 

uname

where priority is the new nice level (39.9 ) for the job. It must be a signed integer between -20 and 20. pid is the ID number (38.3 ) (as shown by ps (38.5 ) ) of the process you want to change. pgrp is the number of a process group (38.3 ) , as shown by ps -l ; this version of the command modifies the priority of all commands in a process group. uname may be a user's name, as shown in /etc/passwd ; this form of the command modifies the priority of all jobs submitted by the user.

A nice level of 19 is the "nicest": the process will run only when nothing else on the system wants to. Negative values make a process get a greater percentage of the CPU's time than the default niceness (which is 0). Again, only the superuser can lower the nice number (raise a process' priority). Users can only raise the nice number (lower the priority) and can modify the priorities of only the jobs they started.

BSD UNIX systems automatically nice jobs after they have accumulated a certain amount of CPU time. This implicitly gives priority to jobs that don't run for a long time, sacrificing users who run long jobs in favor of users who run many short commands. The autonice time varies from system to system, but is usually 10 CPU minutes.

- ML


Previous: 39.10 A nice Gotcha UNIX Power Tools Next: 39.12 What Makes Your Computer Slow? How Do You Fix It?
39.10 A nice Gotcha Book Index 39.12 What Makes Your Computer Slow? How Do You Fix It?

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System