The nice command for Linux to change process priorities

Source: Internet
Author: User

Objective:

VPS universality is not high, many people may have such a feeling, in the implementation of DU, tar and other commands, will cause the system load soared, Apache response slow. This can be mitigated by the nice command changing the process priority. The nice command adjusts the priority of the process in the Linux system.

In layman's words, the process has 19 to 19 of these 39 priorities in a Linux system. -19 top priority, 19 least priority. The default priority for a process is 0. Set the nice value of the process to 19 if you want the process to be the highest priority, or set it to 19 if you want the least amount of system CPU time for the process to take the least precedence.

1. Create a new process and set the priority

Package The documents directory under the current directory, but do not want tar to consume too much CPU:

1 nice-19 tar-zcf pack.tar.gz documents

The method is very simple, which is to add "nice-19" before the original command. Many people may have doubts, the lowest priority is not 19? That's because the "-" in this "-19" represents only the parameter prefixes, so if you want to:

Package The documents directory under the current directory and give the TAR process the highest priority:

1 nice--19 tar-zcf pack.tar.gz documents

2. Change the priority of a process that already exists

Set the PID 1799 process priority to the lowest (19):

1 renice19 1799

Set the PID 1799 process priority to the highest (-19):

1 renice-19 1799

It is likely to be found that the Renice command is in the opposite form of the nice command's precedence parameter. Direct priority as a parameter, you can not add the "-" number, this requires beginners attention.

3. View process Priorities

Use the top command directly to view process priorities.

The role of Linux for process priority adjustment is very obvious, in the actual operation can also be clearly realized.

The nice command for Linux to change process priorities

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.