08-D.9.4: Process Troubleshooting - Process Priorities

Linux - The Penguin Marches On · LibreTexts

0%

Contents

    Text

    Size
    100%
    Theme
    Typeface
    Line length
    Spacing

    From LibreTexts, under CC BY-SA 4.0, as the source states it; its equations are written in TeX, which the PDF shows typeset. This page at LibreTexts.

    08-D.9.4: Process Troubleshooting - Process Priorities

    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-SA 4.0 license and was authored, remixed, and/or curated by LibreTexts.