Linux nice command details how to use Linux nice command

Source: Internet
Author: User

The Linux nice command runs the program in the changed priority order. If no program is specified, the current priority order is printed, and the preset adjustment is 10, the range is-20 (highest priority) to 19 (lowest priority ).

Permission: all users.

Syntax

Nice [-n adjustment] [-adjustment] [-- adjustment = adjustment] [-- help]

[-- Version] [command [arg...]

Parameter description:

  • -N adjustment,-adjustment, -- adjustment = adjustment: add adjustment to the original priority
  • -- Help: Display help messages
  • -- Version: displays version information.

Instance

Set the priority when running the program.

# Vi & // run in the background

[1] 15297

# Nice vi & // set the default priority

[2] 15298

[1] + Stopped vi

# Nice-n 19 vi & // set priority to 19

[3] 15299

[2] + Stopped nice vi

# Nice-n-20 vi & // set the priority to-20

[4] 15300

[3] + Stopped nice-n 19 vi

# Ps-l // display the process

F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD

4 S 0 15278 15212 0 80 0-1208 wait pts/2 00:00:00 bash

0 T 0 15297 15278 0 80 0-2687 signal pts/2 00:00:00 vi

0 T 0 15298 15278 0 90 10-2687 signal pts/2 00:00:00 vi

0 T 0 15299 15278 1 99 19-2687 signal pts/2 00:00:00 vi

4 T 0 15300 15278 3 60-20-2687 signal pts/2 00:00:00 vi

4 R 0 15301 15278 0 80 0-625-pts/2 00:00:00 ps

[4] + Stopped nice-n-20 vi

Add 1 to the priority of ls and execute

Nice-n 1 ls

Add the priority of ls to 10 and execute

Nice ls

Note: priority is the parameter used by the operating system to determine CPU allocation. Linux uses the round-robin algorithm for CPU Scheduling. The higher the priority, the more CPU time you may obtain.

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.