Nice command details

Source: Internet
Author: User
Nice command details-general Linux technology-Linux technology and application information. The following is a detailed description. [Command] nice-adjust the program running priority
[Format] nice [OPTION] [command [arguments...]
[Description]
In
The current program running priority is adjusted based on the specified program running priority, and the command line "command" is run with the new program running priority.
[Arguments...] ". The priority ranges from-20 ~ 19
Among them, the smaller the value, the higher the priority. The larger the value, the lower the priority. The highest priority is-20,
19 has the lowest priority. If the adjusted program running priority is higher than-20, the command line is run with priority-20. If the adjusted program running priority is lower than 19, the adjusted program running priority is run with priority 19.
Line. If the nice command does not specify a priority adjustment value, the program running priority is adjusted by the default value 10, which increases by 10 based on the current program running priority.
If the nice command is run without any parameters, the current program running priority is displayed.
Example 1:
1. # nice
2. 0
3. # In example 1, run the "nice" command without any parameters (see row 1st), so the current program running priority is 0 (see row 2nd ). The default program running priority is 0.
Example 2:
1. # nice
2. 10
3. # in example 2, 1st nice commands adjust the priority of 2nd nice commands by default, which increases by 10 Based on the default program running priority of 0, get the new program running Priority 10, and then run 2nd nice commands with the priority 10; 2nd nice commands show that the current program running priority is 10.
Example 3:
1. # nice
2. 19
3. # In
In Example 3, the 1st nice commands adjust the priority of the 2nd nice commands by default, which increases by 10 Based on the default program running priority of the system, and obtains the new program running priority.
10, and then run 2nd nice commands with a priority of 10; 2nd nice commands adjusted the priority of 3rd nice commands with the default value, both in 2nd nice commands
The program running priority is 20, but 20 is higher than the highest program running priority 19, so the priority 19 is used to run 3rd nice commands; 3rd nice commands
The priority of the current program running is 19.
[Parameter description]
-N, -- adjustment = ADJUST specifies the adjustment value of the program running priority.
The priority ranges from-20 ~ 19. When the adjusted priority is less than-20, run the program with priority-20 (see example 4). When the adjusted priority is greater than 19, run the program with the priority of 19 (see example 5 ).
Example 4:
1. # nice-n-21 nice
2.-20
3. # In example 4, the parameter "-n" is used to specify the adjustment value of the program running priority, the default priority is 0 plus the adjusted value-21 to get the new priority-21 (less than-20), so the final running priority of the program is-20.
Example 5:
1. # nice -- adjustment = 20 nice
2. 19
3. # In Example 5, specify the adjustment value of the program running priority in the form of "-- adjustment = ADJUST, the default priority is 0 and the adjusted value is 20. The new priority is 20 (greater than 19). Therefore, the final running priority of the program is 19.
Note: When "-- adjustment = ADJUST" is used to specify the adjustment value of the program running priority, the equal sign in the middle can be omitted. In Example 5, you can also run the command line "nice -- adjustment 20 nice ".
You can also use the parameter "-ADJUST" to specify the adjustment value of the program running priority. Here, ADJUST is the adjusted value of the specified program running priority, which can be a negative number or a positive number, see example 6.
Example 6:
1. # nice -- 1 nice
2.-1
3. # nice-+ 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 identifier of the priority adjustment value for the specified program running as defined in the syntax, the value after the first character "-" is the adjusted value of the specified program running priority.
In the nice command, you can specify the priority adjustment value for multiple programs at the same time, but only the value specified at the last time 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 values "-20", "+ 9", and "3" are specified through the command line ", however, the priority of the program that takes effect is adjusted to 3 ".
Note: Only users with root permissions can adjust the priority of the high program running. The specified 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 thinkerABC with non-root User Permissions. In this case, when the program priority is increased to 1 level, the operation fails and the system prompts that the permission is insufficient. When the priority is lowered by one level, the operation can be successful.
-- Help: displays the help information of the nice command. For details, see Example 9.
Example 9:
1. # nice -- help
2. Usage: nice [OPTION] [COMMAND [ARG]...]
3. Run COMMAND with an adjusted scheduling priority.
4. With no COMMAND, print the current scheduling priority. ADJUST is 10
5. by default. Range goes from-20 (highest priority) to 19 (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.
11. Report bugs.
12. # In Example 9, run the nice command with the "-- help" parameter. The help information of this command is displayed. See row 2nd in Example 9 ~ 11th rows.
-- Version: output the version information of the nice command. For details, see Example 10.
Example 10:
1. # nice -- version
2. nice (GNU sh-utils) 2.0.12
3. Written by David macenzie.
4.
5. Copyright (C) 2002 Free Software Foundation, Inc.
6. This is free software; see the source for copying conditions. There is NO
7. warranty; not even for MERCHANTABILITY or fitness for a particle PURPOSE.
8. # In Example 10, run the nice command with the parameter "-- version" to display the version information of the command. See the 2nd ~ 7th rows. (Note: This example is the result of running in Red Hat 8.0 .)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.