nice

nice is a utility that allows you to adjust the scheduling priority of processes. It is used to run a command with a modified scheduling priority, which can help control CPU usage and improve system performance. The lower the nice value, the higher the CPU priority a process will have. By default, all processes run with a nice value of 0.

Basic Syntax

nice [options] [command]

Here, options specifies the scheduling priority of the command, which is executed after nice is called. If no options are specified, the command is run at the default priority level of 0.

Commonly Used Options

  • -n: This option sets the priority level of the command. A higher value for n means a lower scheduling priority, while a lower value means a higher scheduling priority. The default priority level is 0.
  • -p: This option sets the priority of the process with the specified process ID (PID). This option is useful when you want to adjust the priority of a running process.

Useful Examples

  • nice -n 10 ./my_program: This runs my_program with a lower scheduling priority, so that other system processes can run more smoothly.
  • nice -n -10 ./my_program: This runs my_program with a higher scheduling priority, giving it more CPU time and resources.
  • nice -n 5 updatedb &: This runs the updatedb command in the background with a lower scheduling priority.
  • nice -p 1234 -n 10: This sets the scheduling priority of the process with PID 1234 to a value of 10.
  • nice -p 1234 -n -10: This sets the scheduling priority of the process with PID 1234 to a value of -10.

Leave a Reply

Your email address will not be published. Required fields are marked *

Comments

  1. […] Once installed, let’s first allow TCP traffic over your SSH port so that you don’t get locked out of…

  2. […] have the option to choose between Password and SSH key selection. Learn more about SSH keys here. It’s recommended…