Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Is it possible to set a new nice level of a running process with a known id?

Does this operation require root access, or just being the owner of the process?

share|improve this question

4 Answers 4

up vote 35 down vote accepted

Terminal

If you're at a terminal you can use renice

renice [-n] priority [[-p] pid ...] [[-g] pgrp ...] [[-u] user ...]

A simple example would be

renice 8 31043
31043: old priority 5, new priority 8

You can also pass it hard flags, but it follows that order

renice -p 31043 -n 5
31043: old priority 8, new priority 5

Priorities work on a scale of -20 tp 20 - The lower the number, the higher it's priority on the system.

If you own the process then you won't need root - however, if the process is owned by another user or if you plan on changing the group/user of the process root (via sudo) will be required.

share|improve this answer
10  
You cannot decrease niceness as user. :) –  htorque Jun 14 '11 at 13:05
1  
As @htorque says, a non-root user can only increase niceness--they cannot decrease niceness, not even to a previous level of niceness the process had, and not even to a previous level of niceness they had themselves reniced the process down from. I recommend editing this answer to incorporate that information. –  Eliah Kagan Oct 14 '12 at 14:35

GUI

  • Alt+F2 and type sudo gnome-system-monitor

Prior to 11.04: System > Administration > System Monitor. Choose Processes.
In 11.04: Alt+A and search for system monitor.

The id's are shown in the image here:

enter image description here

And nice does not require sudo for increasing niceness if you own the task. It does if you need to decrease niceness.

share|improve this answer

Usage of "renice" in terminal is as follows:

Usage:
 renice [-n] <priority> [-p] <pid> [<pid>  ...]
 renice [-n] <priority> [-g] <pgrp> [<pgrp> ...]
 renice [-n] <priority> [-u] <user> [<user> ...]

Options:
 -g, --pgrp <id>        interpret as process group ID
 -h, --help             print help
 -n, --priority <num>   set the nice increment value
 -p, --pid <id>         force to be interpreted as process ID
 -u, --user <name|id>   interpret as username or user ID
 -v, --version          print version

Using "sudo" before command "renice" elevates user to root level and an admin/root password will be required.

So e.g. if you want to elevate process with PID (process ID) 2606 from Normal priority to High priority, you would type in terminal as follows:

sudo renice -n -5 -p 2606
share|improve this answer

Start a command with nice prio

nice -n 20 your_command

Renice process

renice 20 $(pidof your_command_name_like_for_ex_ffmpeg)

20

between -20 and 20

20 is lowest priority

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.