Command nice-to adjust the priority of the program run
"Format" nice [OPTION] [command [arguments ...]]
Description
On top of the current program run priority, adjust the specified merit to the new program run priority, Run command line with the new program run priority [arguments ...]. The priority range is 20 to 19 and 40 levels, where the lower the priority, the higher the value the lower the priority, the higher the priority of 20, and the lowest priority of 19. If the adjusted program runs at a priority higher than-20, the command line is run as priority-20来, and if the adjusted program runs at a priority lower than 19, the command line is run at the priority 19来. If the nice command does not specify a priority adjustment value, 10来 adjusts the program run priority with the default value, which increases by 10 on top of the current program run priority.
If you run command nice without any parameters, the current program run priority is displayed.
Example 1:
1. # Nice
2.0
3. #
In Example 1, the command "nice" is executed without any parameters (see line 1th), so the current program run priority is 0 (see line 2nd). The system default program run priority is 0.
Example 2:
1. # Nice and Nice
2.10
3. #
In Example 2, the 1th Nice command adjusts the priority of the 2nd Nice command with the default value, adding 10 to the system's default program run priority 0, getting a new program run priority of 10, and then running the 2nd Nice command with priority 10来 The 2nd Nice command shows that the current program is running with a priority of 10.
Example 3:
1. # Nice and Nice
2.19
3. #
In Example 3, the 1th Nice command adjusts the priority of the 2nd Nice command with the default value, adding 10 to the system's default program run priority 0, getting a new program run priority of 10, and then running the 2nd Nice command with priority 10来 The 2nd Nice command also adjusts the priority of the 3rd Nice command to run with the default value, adding 10 on top of the 2nd nice command run priority and getting a new program run priority of 20, but 20 is greater than the highest program run priority 19, So run the 3rd Nice command with Priority 19来, and the 3rd Nice command shows that the current program is running at a priority of 19.
"Parameter description"
-N,--adjustment=adjust specifies the adjustment value of the program run priority.
The priority range is -20~19, and when the adjusted priority is less than-20, the program is run with priority-20来 (see Example 4), and when the adjusted priority is greater than 19 o'clock, the program is run with a priority of 19 (see Example 5).
Example 4:
1. # nice-n -21 Nice
2.-20
3. #
In Example 4, the parameter "-n" in the form of the program to specify the priority of the adjustment value, the system default priority 0 plus the adjustment value-21 to obtain a new priority-21 (less than 20), so the final program run priority is-20.
Example 5:
1. #--adjustment=20 Nice
2.19
3. #
In Example 5, the parameter "--adjustment=adjust" in the form of the program to specify the priority of the adjustment value, the system default priority 0 plus the adjustment value 20 to obtain a new priority 20 (greater than 19), so the program will eventually run with a priority of 19.
Note: When you use the "--adjustment=adjust" form to specify an adjustment value for a program's run priority, the middle equals sign can be omitted. In Example 5, you can also run the command line "nice--adjustment."
You can also use the parameter "-adjust" to specify the adjustment value of the program's run priority, where adjust runs the priority adjustment value for the specified program, either negative or positive, as shown in Example 6.
Example 6:
1. #--1 Nice
2.-1
3. #-+1 Nice
4.1
5. # nice-1 Nice
6.1
7. #
In Example 6, the first character "-" in the Parameters "--1", "-+1", and "1" is the syntax definition for the specified program to run a priority adjustment value, and the value after the first character "-" is the adjusted value for the specified program run priority.
In the nice command, you can specify multiple program run priority adjustment values at the same time, but only the last specified value is valid, as shown in Example 7.
Example 7:
1. # nice-n -20--adjustment +19-3 Nice
2.3
3. #
In example 7, the priority adjustment value "20", "+9" and "3" are specified by the command line, but the last program run priority adjustment value is the last specified value "3".
Note: Only users with root privileges can adjust the priority of the high program run, and the specified adjustment value can be negative, as shown in Example 8.
Example 8:
1. # su THINKERABC
2. $ nice-n-1 Nice
3. Nice:cannot Set Priority:permission denied
4. $ nice-n 1 Nice
5.1
6. $
In Example 8, we changed the user to a non-root user thinkerabc, when the program run priority 1 levels when the operation failed, the system prompts insufficient permissions. When the priority level is lowered by 1, the operation succeeds.
--HELP Displays the help information for the Nice command, as described in Example 9.
Example 9:
1. # Nice--help
2. Usage:nice [OPTION] [COMMAND [ARG] ...]
3. Run COMMAND with a adjusted scheduling priority.
4. With no COMMAND, print the current scheduling priority. ADJUST is 10
5. By default. Range goes from-20 (highest) to (lowest).
6.
7.-N,--adjustment=adjust increment priority by ADJUST first
8.--HELP display this Help and exit
9.--version output version information and exit
10.
Report Bugs to < [Email protected]>.
12. #
In Example 9, the Nice command is executed with the parameter "--help", which displays the Help information for the command, as shown in line 2nd ~ 11th of Example 9.
--version output The version information of the Nice command, as described in Example 10.
Example 10:
1. # Nice--version
2. Nice (GNU sh-utils) 2.0.12
3. Written by David MacKenzie.
4.
5. Copyright (C) 2002 Free Software Foundation, Inc.
6. This is the free software; See the source for copying conditions. There is NO
7. Warranty; Not even to merchantability or FITNESS for A particular PURPOSE.
8. #
In Example 10, with the parameter "--version" running the Nice command, the version information of the command is displayed, as shown in Example 10, line 2nd ~ 7th. (Note: This example is the result of running under Red Hat 8.0.) )
Reference documents:
[1] Linux man pages