The Nice Command and How to Use It

November 19, 2022 ・0 comments

The nice command changes the priority of a process. A process with a lower priority will get less CPU time than a process with a higher priority.

The priority of a process can be a number between -20 and 19. A lower number means a higher priority. The default priority is 0.

Here is an example. This command will start the “sleep” command with a priority of 10:

$ nice -n 10 sleep 100

The “sleep” command will sleep for 100 seconds. While it is sleeping, other processes will get more CPU time than usual.

You can use the “top” command to see the priority of a process:

$ top

The “nice” command can be used to give a process a lower priority, so that it gets less CPU time.

The “renice” command can be used to change the priority of a running process.

The “nice” and “renice” commands can only be used by the root user, or by a user with the “CAP_SYS_NICE” capability.

Related commands

ionice – set or get process I/O scheduling class and priority

ps – report a snapshot of the current processes

renice – alter priority of running processes

top – display Linux tasks

Post a Comment

If you can't commemt, try using Chrome instead.