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?
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?
Terminal
If you're at a terminal you can use
renice
A simple example would be
You can also pass it hard flags, but it follows that order (you have to pass priority first and then the pid - if you change the order it will show the usage messagge)
Priorities work on a scale of
-20
to19
- 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.GUI
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:
And nice does not require sudo for increasing niceness if you own the task. It does if you need to decrease niceness.
Start a command with
nice
:Renice process:
Priority could be between -20 and 19. 19 is the lowest priority.
Usage of "renice" in terminal is as follows:
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:
You can also renice a process within top.
Start top
Renice by pressing
r
. You will be prompted for the Process ID (PID) of the process you wish to renice. The default PID is the first process (one consuming the most resources). Confirm with Enter. Set the new nice value from -20 (higher priority) to +19 (lower priority).htop
htop
You can add capability
CAP_SYS_NICE
to user using Linux capabilities system if you don't want to grant full root access to user/script.Unfortunately, it still allows to renice arbitrary process, including those owned by different users.