It is possible to change the execution priority of processes using the commands nice and renice. These commands are extremely useful in multi-user environments, where it is necessary to give more or less processing slices to the various user programs to maintain a stable and organized environment.
$ nice [-n prioritization_setting] [command]
The nice command adjusts a process’s available CPU time to higher or lower priority.
In English the word “nice” means “cool”. If the priority adjustment for a process is a positive number, it means that it is being cooler with the other programs reducing its priority.
If the adjustment is a negative number, it means that the program is being less cool, increasing its execution priority and leaving less CPU time left for other programs.
The possible priority adjustment ranges from —20 (highest priority/least cool) to 19 (coolest, least priority).
If no adjustment value is passed, the nice command will adjust the priority to +10, reducing the process execution time.
$ nice updatedb &
In this example, the updatedb command has lower execution priority.
$ nice —n —10 payroll
In this example, the payroll command will be executed with higher priority.
The renice command adjusts the execution priority of processes that are already running. By default, the renice command takes the PID of a particular process as a parameter. The priority setting is an integer ranging from —20 (highest priority) to +20 (execute anything before this process).
The most common options are:
# renice -1 987 -u daemon root -p 32
In this example, the process number PID 987, PID 32, and all processes that daemon and root users own will have higher priority.
The sudo command on Linux executes a given command as if it were another user.…
The ss command on Linux is extremely useful for investigating sockets, providing various information about…
Free Linux command shows the amount of total memory in use and available, as well…
The shell has structures for testing conditions and executing certain program sequences several times (loop),…
The /etc/fstab file stores the configuration of which devices should be mounted and what is…
The Netcat Command in Linux or nc is a utility used to do “almost anything”…
This website uses cookies.