Using renice to Change Priorities

You can use nice to change the priority of a process when you launch it, but sometimes you may need to change the priority of a process that's already running. For instance, if you find your system is running sluggishly because of some lengthy CPU-intensive process, you might want to reduce that process's priority without restarting it. To do so, you use a tool called renice, which has the following syntax:

renice priority [[-p] pid [...]] [[-g] group [...]] [[-u] user [...]]

In order to change the priority of processes, you must have some way to specify what processes to change. This is the purpose of the -p, -g, and -u options, which enable you to specify processes by PID, group (aka process group), or username, respectively. If you specify a group or user, renice changes the priority of all of that group's or user's processes.

The renice priority is specified in absolute terms, unlike the nice adjustment. There's also no -n or dash preceding this number. For instance, if a process is running with a nice value of 10 and you want to change it to a value of 15, you'd pass 15 as the priority, not 5. Nonetheless, only root may increase a process's priority (that is, reduce the nice value). Also, only root may modify the priorities of any process owned by another user.

A few examples of renice in action may be in order:

# renice 5 -u hoggy piggy -g porcine

The first example sets the priority of the process with PID 24301 to -2, thereby giving that process precedence over most others. The second example sets the priority of PID 1734 and of all processes owned by the user hoggy to 10, in all probability reducing those priorities. The final example sets the priority of all processes owned by hoggy, piggy, or any member of the porcine group to 5, in all probability reducing the priority of those processes.

Many process-monitoring tools, including top, GNOME System Monitor, and KDE System Guard, also provide the ability to alter a process's priority. In top, you type r and the program prompts for a PID. In the GUI tools, right-clicking a process produces a context menu from which you can select an option to change the priority.

Team LIB

1 previous

Team LiB

^ previous

0 0

Post a comment