reniceChange the priority of a running process
renice changes the nice value of processes that are already running, by PID, process group or user. It's how you calm down a runaway job without killing it. Normal users can only increase niceness (lower priority); going back down needs root.
renice [-n] PRIORITY [-p] PID... | -g PGRP... | -u USER...A report worker is eating a full core and the API is slowing down. Lower its priority instead of killing it.
sudoNeeded to renice other users' processes or to lower a nice value.
renice is a loop around the setpriority(which, who, prio) system call, with which set to PRIO_PROCESS (-p), PRIO_PGRP (-g) or PRIO_USER (-u). It first calls getpriority() to print the old value, then sets the new one and reports both. The kernel checks permissions: you must own the target, and lowering the nice value below its current value needs CAP_SYS_NICE or a high enough RLIMIT_NICE. On Linux, nice is per thread, and PRIO_PROCESS with a PID changes only the thread whose ID equals that PID (the main thread). PRIO_PGRP and PRIO_USER walk every thread of every matching process. So for a multi-threaded server, renice -g PGID or renicing each TID in /proc/PID/task is what actually lowers the whole process. New threads inherit the value of the thread that creates them.
-n NThe new nice value (-20..19)-p PIDTarget processes by ID (the default target type)-g PGRPTarget every process (and thread) in a process group-u USERTarget every process owned by a user--relativeTreat -n as an increment instead of an absolute value+N / NOld syntax: renice +5 -p PID sets nice to 5renice -n 10 -p PID on a Java or Node server and assuming it's doneNice is per thread on Linux; -p changes only the main thread, while worker threads keep the old value.
renice -n 10 -g PGID, or renice each ID in /proc/PID/taskRaising niceness during an incident, then trying to undo it as a normal userLowering niceness needs root, even for your own processes.
Use sudo renice, or restart the processRenicing a user's processes to fix things long-termrenice only affects processes running now; new ones start at the default again.
Nice= in the systemd unit, or limits.conf priority for the userTry these on a Linux machine of your own. Each task has a hint and a solution.
Start `sleep 900 &` and change its niceness to 12. Confirm with ps.
Try to set that sleep back to niceness 0 without sudo. What happens? Now do it with sudo.
Raise the niceness of all your own processes to 5 in one command.
reniceChange the priority of a running process
renice changes the nice value of processes that are already running, by PID, process group or user. It's how you calm down a runaway job without killing it. Normal users can only increase niceness (lower priority); going back down needs root.
renice [-n] PRIORITY [-p] PID... | -g PGRP... | -u USER...A report worker is eating a full core and the API is slowing down. Lower its priority instead of killing it.
sudoNeeded to renice other users' processes or to lower a nice value.
renice is a loop around the setpriority(which, who, prio) system call, with which set to PRIO_PROCESS (-p), PRIO_PGRP (-g) or PRIO_USER (-u). It first calls getpriority() to print the old value, then sets the new one and reports both. The kernel checks permissions: you must own the target, and lowering the nice value below its current value needs CAP_SYS_NICE or a high enough RLIMIT_NICE. On Linux, nice is per thread, and PRIO_PROCESS with a PID changes only the thread whose ID equals that PID (the main thread). PRIO_PGRP and PRIO_USER walk every thread of every matching process. So for a multi-threaded server, renice -g PGID or renicing each TID in /proc/PID/task is what actually lowers the whole process. New threads inherit the value of the thread that creates them.
-n NThe new nice value (-20..19)-p PIDTarget processes by ID (the default target type)-g PGRPTarget every process (and thread) in a process group-u USERTarget every process owned by a user--relativeTreat -n as an increment instead of an absolute value+N / NOld syntax: renice +5 -p PID sets nice to 5renice -n 10 -p PID on a Java or Node server and assuming it's doneNice is per thread on Linux; -p changes only the main thread, while worker threads keep the old value.
renice -n 10 -g PGID, or renice each ID in /proc/PID/taskRaising niceness during an incident, then trying to undo it as a normal userLowering niceness needs root, even for your own processes.
Use sudo renice, or restart the processRenicing a user's processes to fix things long-termrenice only affects processes running now; new ones start at the default again.
Nice= in the systemd unit, or limits.conf priority for the userTry these on a Linux machine of your own. Each task has a hint and a solution.
Start `sleep 900 &` and change its niceness to 12. Confirm with ps.
Try to set that sleep back to niceness 0 without sudo. What happens? Now do it with sudo.
Raise the niceness of all your own processes to 5 in one command.