nice 명령어 (AIX 5.3·6.1)

핵심 정리

  • 명령을 보통보다 낮은 우선순위(큰 nice 값)로 실행합니다. 값을 주지 않으면 nice 값을 10만큼 올립니다.
  • nice 값의 범위는 -20~19이고 19가 가장 낮은 우선순위입니다. 범위를 넘으면 한계값으로 맞춥니다.
  • 우선순위를 높이는(음수 증가값) 것은 root만 할 수 있습니다. 권한 없이 시도해도 오류 없이 원래 우선순위로 실행합니다.
  • -n 증가값이 표준 형식이고, 옛 형식 -증가값(nice --10은 -10)도 받습니다.
  • 현재 nice 값은 ps -l의 NI 열로 봅니다. 실행 중인 프로세스는 renice로 바꿉니다.
  • csh의 내장 nice는 /usr/bin/nice와 다르게 동작할 수 있습니다. AIX 5.3과 6.1 문서의 내용이 같습니다.
항목 내용
버전 AIX 5.3, AIX 6.1 (두 버전 내용 같음)
원문 IBM Commands Reference — 5.3 Volume 4, 6.1 Volume 4
파일 /usr/bin/nice
관련 명령어 renice, nohup, ps, csh

목적

명령을 낮은 우선순위로 실행합니다.

영어 원문

Runs a command at a lower or higher priority.

구문

text
nice [ -Increment | -n Increment ] Command [ Argument ... ]

설명

nice 명령은 명령을 보통의 우선순위보다 낮은 우선순위로 실행하게 합니다. Command 매개변수는 시스템에 있는 실행 파일의 이름입니다. Increment 값을 지정하지 않으면 증가값 10이 기본입니다. 더 높은 우선순위로 실행하려면 root 권한이 있어야 합니다. 프로세스의 우선순위를 흔히 nice 값이라고 부릅니다.

nice 값은 -20~19이며 19가 가장 낮은 우선순위입니다. 예를 들어 보통 우선순위 10으로 도는 명령에 증가값 5를 주면 더 낮은 우선순위 15로 돌고 더 느려집니다. 권한 없이 우선순위를 높이려 해도 nice는 오류 메시지를 내지 않으며, 우선순위를 바꾸지 않고 평소처럼 명령을 시작합니다.

시스템은 nice 값으로 실행 중인 프로세스의 현재 우선순위를 계산합니다. 명령의 nice 값은 ps -l 출력의 NI 열에서 봅니다.

참고: csh 명령에는 nice라는 내장 명령이 있습니다. /usr/bin/nice와 csh의 nice는 같게 동작하지 않을 수 있으니 csh 명령 설명을 참고합니다.

영어 원문

The nice command lets you run a command at a priority lower than the command's normal priority. The Command parameter is the name of any executable file on the system. If you do not specify an Increment value the nice command defaults to an increment of 10. You must have root user authority to run a command at a higher priority. The priority of a process is often called its nice value.

The nice value can range from -20 to 19, with 19 being the lowest priority. For example, if a command normally runs at a priority of 10, specifying an increment of 5 runs the command at a lower priority, 15, and the command runs slower. The nice command does not return an error message if you attempt to increase a command's priority without the appropriate authority. Instead, the command's priority is not changed, and the system starts the command as it normally would.

The nice value is used by the system to calculate the current priority of a running process. Use the ps command with the -l flag to view a command's nice value. The nice value appears under the NI heading in the ps command output.

Note: The csh command contains a built-in command named nice. The /usr/bin/nice command and the csh command's nice command do not necessarily work the same way. For information on the csh command's nice command, see the csh command.

플래그

플래그 설명
-Increment 명령의 우선순위를 올리거나 내립니다. 양수와 음수를 쓸 수 있으며, 양수는 우선순위를 낮추고 음수는 높입니다. 음수는 root 권한이 있는 사용자만 쓸 수 있습니다. nice 값이 -20~19를 넘게 되면 넘은 쪽 한계값으로 정합니다. -n Increment와 같습니다.
-n Increment -Increment와 같습니다.
영어 원문
  • -Increment — Increments a command's priority up or down. You can specify a positive or negative number. Positive increment values reduce priority. Negative increment values increase priority. Only users with root authority can specify a negative increment. If you specify an increment value that would cause the nice value to exceed the range of -20 to 19, the nice value is set to the value of the limit that was exceeded. This flag is equivalent to the -n Increment flag.
  • -n Increment — This flag is equivalent to the -Increment flag.

종료 상태

Command로 지정한 명령이 시작되면 그 명령의 종료 상태가 nice의 종료 상태입니다. 그렇지 않으면 다음 값 중 하나로 끝납니다.

값 뜻
1~125 nice에서 오류가 났습니다.
126 Command로 지정한 명령을 찾았지만 실행할 수 없었습니다.
127 Command로 지정한 명령을 찾을 수 없었습니다.
영어 원문

If the command specified by the Command parameter is started, the exit status of the nice command is the exit status of the command specified by the Command parameter. Otherwise, the nice command exits with one of the following values:

  • 1-125 — An error occurred in the nice command.
  • 126 — The command specified by the Command parameter was found but could not be invoked.
  • 127 — The command specified by the Command parameter could not be found.

예제

  1. 아주 낮은 우선순위로 실행합니다. cc를 백그라운드에서, nice의 기본보다 낮은 우선순위로 실행합니다.
bash
nice -n 15 cc -c *.c &
  1. 아주 높은 우선순위로 실행합니다. wall을 모든 사용자 프로세스보다 높은 우선순위로 실행하므로 시스템의 다른 작업이 느려집니다. <<end와 end는 끝 줄 앞까지 입력한 글을 명령의 표준 입력으로 쓰는 here 문서입니다. root 권한 없이 실행하면 wall은 보통 우선순위로 실행됩니다.
bash
nice --10 wall <<end
System shutdown in 2 minutes!
end
  1. 낮은 우선순위로 실행합니다. 백그라운드가 아니므로 그동안 터미널로 다른 일을 할 수 없습니다.
bash
nice cc -c *.c
  1. 낮은 우선순위로 백그라운드에서 실행합니다. cc가 도는 동안 터미널에서 다른 명령을 실행할 수 있습니다.
bash
nice cc -c *.c &
영어 원문
  1. To specify a very low priority, enter: nice -n 15 cc -c *.c &

This example runs the cc command in the background at a lower priority than the default priority set by the nice command.

  1. To specify a very high priority, enter: nice --10 wall <<end System shutdown in 2 minutes! end

This example runs the wall command at a higher priority than all user processes, which slows down everything else running on the system. The <<end and end portions of the example define a here document, which uses the text entered before the end line as standard input for the command.

Note: If you do not have root user authority when you run this command, the wall command runs at the normal priority.

  1. To run a command at low priority, enter: nice cc -c *.c

This example runs the cc command at low priority.

Note: This does not run the command in the background. The workstation is not available for doing other things.

  1. To run a low-priority command in the background, enter: nice cc -c *.c &

This example runs the cc command at low priority in the background. The workstation is free to run other commands while the cc command is running. Refer to the Shells in Operating system and device managementfor more information on background (asynchronous) processing.

파일

파일 설명
/usr/bin/nice nice 명령이 들어 있습니다.

관련 명령어: nohup, renice, csh

영어 원문
  • /usr/bin/nice — Contains the nice command.

Related reference:

  • nohup Command
  • renice Command

Related information:

  • csh command
  • Shells command
  • Controlling contention for the microprocessor

리눅스(GNU)와 다른 점

GNU nice도 범위(-20~19), 기본 증가값 10, -n과 옛 형식 -증가값이 같습니다. 인수 없이 실행하면 GNU nice는 현재 nice 값을 출력하지만, AIX 문서에는 Command가 필수로 되어 있습니다.