Skip to main content
Engineering LibreTexts

08-D.9.4: Process Troubleshooting - Process Priorities

  • Page ID
    37615
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)

    Working with nice and renice Command

    The nice command in Linux helps in execution of a program/process with modified scheduling priority. It launches a process with a user-defined scheduling priority. In this, if we give a process a higher priority, then Kernel will allocate more CPU time to that process, whereas the renice command allows you to change and modify the scheduling priority of an already running process. Linux Kernel schedules the process and allocates CPU time accordingly for each of them.

    • To check the nice value of a process:
    pbmac@pbmac-server $ ps -el | grep terminal
    0 S  1000 13197  2034  0  80   0 - 201301 poll_s ?       00:00:14 gnome-terminal-
    

    The highlighted value is the nice value of the process - in this case 0.

    • To set the priority of a process:
    pbmac@pbmac-server $ nice -10 gnome-terminal
    pbmac@pbmac-server $ ps -el | grep terminal
    4 S     0 13197  2034  1  70 -10 - 160436 poll_s ?       00:00:00 gnome-terminal-
    

    This will set the nice value of the specified process.

    • To change the priority of the running process:
    pbmac@pbmac-server $ sudo renice -n 15 -p 13197
    pbmac@pbmac-server $ ps -el | grep terminal
    4 S     0 13197  2034  0  95  15 - 160836 poll_s ?       00:00:00 gnome-terminal-
    

    This will change the priority of the process with PID 13197

    • To change the priority of all programs of a specific group.
    pbmac@pbmac-server $ sudo renice -n 10 -g 4

    This command will set all the processes of GID 4 priority to 10.

    • To change the priority of all programs of a specific user:
    pbmac@pbmac-server $ sudo renice -n 10 -u 2

    This will set all the processes of UID 2 to 10.

    Adapted from:
    "Nice and Renice Command in Linux with Examples" by manav014, Geeks for Geeks is licensed under CC BY-SA 4.0


    08-D.9.4: Process Troubleshooting - Process Priorities is shared under a CC BY-NC license and was authored, remixed, and/or curated by LibreTexts.

    • Was this article helpful?