Adjust process priority in linux

Source: Internet
Author: User

In linux, adjusting the priority of a process determines whether the process is preferentially processed by resources allocated by the cpu. When the cpu resources are sufficient, every running process can be allocated enough resources for processing. At this time, adjusting the priority of the process makes no sense. If the cpu resources are insufficient, top view when the cpu usage reaches 90% or above, the process with a higher priority will be preferentially allocated resources for execution. If you have a very important task to execute at this time, such as transmitting a very important data or preparing to send a very urgent email to the customer, you want these tasks to be completed first, you need to adjust the priority of these tasks. Priority = priority coefficient + nice priority coefficient is determined by the system kernel. You can manually change the nice value if you cannot change it. The value range is-20 ~ 19 The lower the priority value, the higher the priority. The higher the priority value, the lower the priority. So if you want to adjust it to the highest priority, set nice to-20. If you want to adjust it to the lowest priority, set nice to 19. Adjust Priority: 1. Adjust the task before it is run # nice-N-20 sh/xxx. sh -- run xxx with the highest priority. sh script # nice-n19 sh/xxx. sh -- run xxx with the lowest priority. sh Script 2. When the task has started running, adjust ① # top -- view the current running status of the system process> r -- type A small r> PID to renice: -- prompt to enter the pid of the running process> Renice PID 23302 to value: -- set the nice value of the process, adjust ② # renice-20 PID as needed change the nice value of the process to-20 # renice 19 PID change the nice value of the process to 19

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.