[AIX 운영 체제와 장치 관리 14] 시스템 정지 관리(shconf·shdaemon, 우선순위·유실 I/O 정지 감지)와 프로세스 관리(ps 플래그, renice, kill, 바인딩, 멈춘 프로세스 처리)

핵심 정리

  • shdaemon은 init이 띄우는 우선순위 0 데몬으로, 지정 시간 동안 실행된 가장 낮은 우선순위 스레드가 문턱보다 높으면(숫자가 작으면) 정한 동작을 합니다. 기본으로 켜진 동작은 우선순위 60·120초의 복구용 getty뿐입니다.
  • 유실 I/O 감지는 LVM의 도움으로 I/O 버퍼를 지켜보다 대기 시간이 문턱을 넘으면 오류 로그에 기록하고, 설정에 따라 콘솔 메시지나 크래시 후 재부팅을 합니다.
  • ps -ef는 커널 프로세스를 뺀 전체를, ps -fu UserID는 사용자별 프로세스를 보여 줍니다. 대시로 시작하는 프로세스 지정 플래그면 Default1 열, 대시 없는 플래그면 Default2 열이 나옵니다.
  • kill은 기본으로 SIGTERM(15)을 보냅니다. 처리기가 정리할 기회를 주므로 SIGKILL(9)보다 낫습니다. 좀비(<defunct>)는 부모가 끝나야 사라지며, 근본 해결은 sigaction으로 SIGCHLD를 무시하게 고치는 것입니다.
  • 실행 큐가 여럿이면 깨어난 스레드가 최대 10ms 늦게 실행될 수 있습니다. RT_GRQ=ON(전역 실행 큐)이나 실시간 커널 옵션과 RT_MPC=ON으로 대응합니다.
항목 내용
버전 AIX 6.1 (5.3판과 거의 같음)
원문 Operating system and device management — 5.3판 2023쪽·176183쪽, 6.1판 142~151쪽
관련 명령어 shconf, ps, who -u, svmon, renice, kill, bindprocessor, setsenv, stty sane, bosdebug -R on
SMIT 빠른 경로 smit shd, smit shstatus, smit shpriocfg, smit shreset, smit shliocfg, smit shlioreset, smit bindproc, smit ubindproc

시스템 정지 관리로 사용자는 업무에 중요한 응용 프로그램을 계속 실행하면서 응용 프로그램 가용성을 높일 수 있습니다. 시스템 정지 감지는 시스템 관리자에게 문제 가능성을 알리고, 관리자가 root로 로그인하거나 시스템을 재부팅해 문제를 해결할 수 있게 합니다.

shconf 명령

shconf 명령은 시스템 정지 감지를 켜면 호출됩니다. shconf 명령은 어떤 이벤트를 감시하고 그런 이벤트가 생기면 어떤 동작을 할지 구성합니다. 다음 동작 가운데 어느 것이든, 그리고 검사할 우선순위 수준, 그 우선순위 이하에서 실행되는 프로세스나 스레드가 없는 제한 시간, 경고 동작의 터미널 장치, getty 명령 동작을 지정할 수 있습니다.

  • errlog 파일에 오류 기록
  • 시스템 콘솔(영숫자 콘솔)이나 지정한 TTY에 경고 메시지 표시
  • 시스템 재부팅
  • 사용자가 root로 로그인해 명령을 실행할 수 있게 특수 getty 제공
  • 명령 실행

명령 실행과 특수 getty 제공 옵션에서는 시스템 정지 감지가 특수 getty 명령이나 지정한 명령을 가장 높은 우선순위로 실행합니다. 특수 getty 명령은 자기가 우선순위 0으로 실행 중인 복구용 getty라는 경고 메시지를 출력합니다. 다음 표는 우선순위 정지 감지의 여러 동작과 관련 기본 매개변수입니다. 감지 종류마다 동작은 하나만 켜집니다.

옵션 사용 여부 우선순위 제한 시간(초)
errlog 파일에 오류 기록 꺼짐 60 120
경고 메시지 표시 꺼짐 60 120
복구용 getty 제공 켜짐 60 120
명령 실행 꺼짐 60 120
시스템 재부팅 꺼짐 39 300

참고: 콘솔에서 복구용 getty 실행을 켜면 shconf 명령은 inittab에서 콘솔 로그인과 연결된 getty 명령에 -u 플래그를 더합니다.

유실 I/O 감지에서는 제한 시간 값을 설정하고 다음 동작을 켤 수 있습니다.

  • 경고 메시지 표시 — 꺼짐
  • 시스템 재부팅 — 꺼짐

유실 I/O 이벤트는 Web-based System Manager 오류 로그 파일에 기록됩니다.

shdaemon 데몬

shdaemon 데몬은 init이 띄우고 우선순위 0으로 실행되는 프로세스입니다. 구성 정보를 가져오고, 작업 구조를 초기화하고, 사용자가 설정한 감지 시간을 시작해 시스템 정지 감지를 맡습니다.

관련 개념

  • 우선순위 정지 감지 — AIX는 시스템 정지 상황을 감지하고 사용자가 정의한 동작에 따라 복구를 시도할 수 있습니다.
  • 유실 I/O 정지 감지 — AIX는 시스템 정지 상황을 감지하고 사용자가 정의한 동작에 따라 복구를 시도할 수 있습니다.
영어 원문

Managing system hang

System hang management allows users to run mission-critical applications continuously while improving application availability. System hang detection alerts the system administrator of possible problems and then allows the administrator to log in as root or to reboot the system to resolve the problem.

shconf command

The shconf command is invoked when System Hang Detection is enabled. The shconf command configures which events are surveyed and what actions are to be taken if such events occur. You can specify any of the following actions, the priority level to check, the time out while no process or thread executes at a lower or equal priority, the terminal device for the warning action, and the getty command action:

  • Log an error in errlog file

  • Display a warning message on the system console (alphanumeric console) or on a specified TTY

  • Reboot the system

  • Give a special getty to allow the user to log in as root and launch commands

  • Launch a command

For the Launch a command and Give a special getty options, system hang detection launches the special getty command or the specified command at the highest priority. The special getty command prints a warning message that it is a recovering getty running at priority 0. The following table captures the various actions and the associated default parameters for priority hang detection. Only one action is enabled for each type of detection.

Option Enablement Priority Timeout (seconds)
Log an error in errlog file disabled 60 120
Display a warning message disabled 60 120
Give a recovering getty enabled 60 120
Launch a command disabled 60 120
Reboot the system disabled 39 300

Note: When Launch a recovering getty on a console is enabled, the shconf command adds the -u flag to the getty command in the inittab that is associated with the console login.

For lost IO detection, you can set the time out value and enable the following actions:

  • Display a warning message — disabled
  • Reboot the system — disabled

Lost IO events are recorded in the Web-based System Manager error log file.

shdaemon daemon

The shdaemon daemon is a process that is launched by init and runs at priority 0 (zero). It is in charge of handling system hang detection by retrieving configuration information, initiating working structures, and starting detection times set by the user.

Related concepts

Priority hang detection AIX can detect system hang conditions and try to recover from such situations, based on user-defined actions. Lost I/O hang detection AIX can detect system hang conditions and try to recover from such situations, based on user-defined actions.

시스템 정지 감지 구성

SMIT 관리 도구에서 시스템 정지 감지 구성을 관리할 수 있습니다.

SMIT 메뉴 옵션으로 감지 메커니즘을 켜거나 끄고, 기능의 현재 상태를 보고, 현재 구성을 바꾸거나 볼 수 있습니다. 시스템 정지 감지 메뉴의 빠른 경로는 다음과 같습니다.

빠른 경로 메뉴
smit shd 시스템 정지 감지 관리
smit shstatus 시스템 정지 감지 상태
smit shpriocfg 우선순위 문제 감지 특성 변경/표시
smit shreset 기본 우선순위 문제 구성 복원
smit shliocfg 유실 I/O 감지 특성 변경/표시
smit shlioreset 기본 유실 I/O 감지 구성 복원

shconf 명령으로도 시스템 정지 감지를 관리할 수 있습니다.

영어 원문

Configuring system hang detection

You can manage the system hang detection configuration from the SMIT management tool.

SMIT menu options allow you to enable or disable the detection mechanism, display the current state of the feature, and change or show the current configuration. The fast paths for system hang detection menus are:

smit shd

Manage System Hang Detection

smit shstatus

System Hang Detection Status

smit shpriocfg

Change/Show Characteristics of Priority Problem Detection

smit shreset

Restore Default Priority Problem Configuration

smit shliocfg

Change/Show Characteristics of Lost I/O Detection

smit shlioreset

Restore Default Lost I/O Detection Configuration

You can also manage system hang detection using the shconf command.

우선순위 정지 감지

AIX는 시스템 정지 상황을 감지하고 사용자가 정의한 동작에 따라 복구를 시도할 수 있습니다.

모든 프로세스(스레드라고도 함)는 어떤 우선순위로 실행됩니다. 이 우선순위는 0~126 범위에서 숫자가 거꾸로입니다. 0이 가장 높고 126이 가장 낮은 우선순위입니다. 모든 스레드의 기본 우선순위는 60입니다. 어떤 사용자든 nice 명령으로 프로세스 우선순위를 낮출 수 있습니다. root 권한이 있으면 프로세스 우선순위를 높일 수도 있습니다.

커널 스케줄러는 늘 실행할 수 있는 가장 높은 우선순위 스레드를 골라 CPU에 올립니다. 그래서 우선순위가 높은 스레드가 충분히 많으면 기계를 완전히 붙잡아 낮은 우선순위 스레드가 전혀 실행되지 못할 수 있습니다. 실행 중인 스레드가 기본값 60보다 높은 우선순위이면 모든 일반 셸과 로그인이 막혀 시스템이 멈춘 것처럼 보일 수 있습니다.

시스템 정지 감지 기능은 이 상황을 감지하고 시스템 관리자가 복구할 수단을 줍니다. 이 기능은 가장 높은 프로세스 우선순위로 실행되는 데몬(shdaemon)으로 구현됩니다. 이 데몬은 지정한 간격 동안 실행된 가장 낮은 우선순위 스레드를 커널에 묻습니다. 그 우선순위가 구성한 문턱보다 높으면 데몬은 여러 동작 가운데 하나를 할 수 있습니다. 각 동작은 따로 켤 수 있고, 각각 어떤 우선순위와 시간 간격에서든 작동하도록 구성할 수 있습니다. 동작과 기본값은 다음과 같습니다.

text
    Action           Default    Default     Default   Default
                     Enabled    Priority    Timeout   Device
1)  Log an error        no         60          2
2)  Console message     no         60          2      /dev/console
3)  High priority       yes        60          2      /dev/tty0
    login shell
4)  Run a command at    no         60          2
    high priority
5)  Crash and reboot    no         39          5

관련 개념

  • 시스템 정지 관리 — 시스템 정지 관리로 업무에 중요한 응용 프로그램을 계속 실행하면서 가용성을 높일 수 있습니다. 시스템 정지 감지는 관리자에게 문제 가능성을 알리고 root로 로그인하거나 재부팅해 해결할 수 있게 합니다.
영어 원문

Priority hang detection

AIX can detect system hang conditions and try to recover from such situations, based on user-defined actions.

All processes (also known as threads) run at a priority. This priority is numerically inverted in the range 0-126. Zero is highest priority and 126 is the lowest priority. The default priority for all threads is 60. The priority of a process can be lowered by any user with the nice command. Anyone with root authority can also raise a process's priority.

The kernel scheduler always picks the highest priority runnable thread to put on a CPU. It is therefore possible for a sufficient number of high priority threads to completely tie up the machine such that low priority threads can never run. If the running threads are at a priority higher than the default of 60, this can lock out all normal shells and logins to the point where the system appears hung.

The System Hang Detection feature provides a mechanism to detect this situation and allow the system administrator a means to recover. This feature is implemented as a daemon (shdaemon) that runs at the highest process priority. This daemon queries the kernel for the lowest priority thread run over a specified interval. If the priority is above a configured threshold, the daemon can take one of several actions. Each of these actions can be independently enabled, and each can be configured to trigger at any priority and over any time interval. The actions and their defaults are:

text
    Action           Default    Default     Default   Default
                     Enabled    Priority    Timeout   Device
1)  Log an error        no         60          2
2)  Console message     no         60          2      /dev/console
3)  High priority       yes        60          2      /dev/tty0
    login shell
4)  Run a command at    no         60          2
    high priority
5)  Crash and reboot    no         39          5

Related concepts

Managing system hang System hang management allows users to run mission-critical applications continuously while improving application availability. System hang detection alerts the system administrator of possible problems and then allows the administrator to log in as root or to reboot the system to resolve the problem.

유실 I/O 정지 감지

AIX는 시스템 정지 상황을 감지하고 사용자가 정의한 동작에 따라 복구를 시도할 수 있습니다.

I/O 오류 때문에 I/O 경로가 막히면 그 경로의 이후 I/O가 영향을 받습니다. 이런 상황에서는 운영 체제가 사용자에게 알리고 사용자가 정의한 동작을 실행하는 것이 꼭 필요합니다. 유실 I/O 감지와 통지의 일부로 shdaemon은 논리 볼륨 관리자의 도움을 받아 일정 기간 I/O 버퍼를 감시하고 너무 오래 대기 중인 I/O가 있는지 확인합니다. 대기 시간이 shconf 파일에 정의한 문턱 대기 시간을 넘으면 유실 I/O로 감지하고 다음 동작을 합니다. 유실 I/O에 관한 정보는 오류 로그에 기록됩니다. 또 shconf 파일의 설정에 따라 유실 I/O 상황에서 복구하려고 시스템을 재부팅할 수 있습니다.

유실 I/O 감지에서는 제한 시간 값을 설정하고 다음 동작도 켤 수 있습니다.

동작 기본 사용 기본 장치
콘솔 메시지 아니요 /dev/console
크래시 후 재부팅 아니요 -

시스템 정지 감지에 관한 자세한 내용은 시스템 정지 관리를 봅니다.

영어 원문

Lost I/O hang detection

AIX can detect system hang conditions and try to recover from such situations, based on user-defined actions.

Because of I/O errors, the I/O path can become blocked and further I/O on that path is affected. In these circumstances it is essential that the operating system alert the user and execute user defined actions. As part of the Lost I/O detection and notification, the shdaemon, with the help of the Logical Volume Manager, monitors the I/O buffers over a period of time and checks whether any I/O is pending for too long a period of time. If the wait time exceeds the threshold wait time defined by the shconf file, a lost I/O is detected and further actions are taken. The information about the lost I/O is documented in the error log. Also based on the settings in the shconf file, the system might be rebooted to recover from the lost I/O situation.

For lost I/O detection, you can set the time out value and also enable the following actions:

Action Default Enabled Default Device
Console message no /dev/console
Crash and reboot no -

For more information on system hang detection, see Managing system hang.

Related concepts

Managing system hang System hang management allows users to run mission-critical applications continuously while improving application availability. System hang detection alerts the system administrator of possible problems and then allows the administrator to log in as root or to reboot the system to resolve the problem.

프로세스 관리

프로세스는 운영 체제가 시스템 자원 사용을 제어하는 데 쓰는 개체입니다. 스레드가 프로세서 시간 소비를 제어할 수 있지만, 대부분의 시스템 관리 도구는 여전히 스레드 자체가 아니라 스레드가 실행 중인 프로세스를 가리키게 합니다.

다음 일을 하는 도구가 있습니다.

  • 프로세스의 생성, 취소, 신원, 자원 소비 관찰
    • ps 명령은 프로세스 ID, 사용자, CPU 시간 소비 등 여러 속성을 보고합니다.
    • who -u 명령은 로그인한 사용자의 셸 프로세스 ID를 보고합니다.
    • svmon 명령은 프로세스의 실제 메모리 소비를 보고합니다(svmon 명령은 Performance Toolbox Version 3: Guide and Reference를 봅니다).
    • acct 명령 메커니즘은 프로세스가 끝날 때 자원 사용을 요약하는 레코드를 씁니다.
  • 프로세스가 CPU를 두고 경쟁하는 우선순위 수준 제어
    • nice 명령은 지정한 프로세스 우선순위로 명령을 실행합니다.
    • renice 명령은 주어진 프로세스의 우선순위를 바꿉니다.
  • 통제를 벗어난 프로세스 종료
    • kill 명령은 프로세스 하나 이상에 종료 신호를 보냅니다.

관련 개념

  • 시스템 계정 — 시스템 계정 유틸리티로 여러 시스템 자원의 개인·그룹 사용을 모으고 보고할 수 있습니다.
영어 원문

Process management

The process is the entity that the operating system uses to control the use of system resources. Threads can control processor-time consumption, but most system management tools still require you to refer to the process in which a thread is running, rather than to the thread itself.

Tools are available to:

  • Observe the creation, cancellation, identity, and resource consumption of processes – The ps command is used to report process IDs, users, CPU-time consumption, and other attributes. – The who -u command reports the shell process ID of logged-on users. – The svmon command is used to report process real-memory consumption. (See Performance Toolbox Version 3: Guide and Reference for information on the svmon command.) – The acct command mechanism writes records at process termination summarizing the process's resource use.

  • Control the priority level at which a process contends for the CPU. – The nice command causes a command to be run with a specified process priority. – The renice command changes the priority of a given process.

  • Terminate processes that are out of control. – The kill command sends a termination signal to one or more processes.

Related concepts

System accounting The system accounting utility allows you to collect and report on individual and group use of various system resources.

프로세스 감시

시스템 관리자는 프로세스를 관리할 수 있습니다.

ps 명령은 시스템의 프로세스를 관찰하는 주 도구입니다. ps 명령의 플래그는 대부분 다음 두 범주 가운데 하나에 듭니다.

  • 출력에 넣을 프로세스 종류를 지정하는 플래그
  • 그 프로세스의 어떤 속성을 보여 줄지 지정하는 플래그

시스템 관리에 가장 널리 쓰이는 ps 형태는 다음과 같습니다.

명령 설명
ps -ef 커널 프로세스가 아닌 모든 프로세스를 사용자 ID, 프로세스 ID, 최근 CPU 사용, 총 CPU 사용, 프로세스를 시작한 명령(매개변수 포함)과 함께 나열합니다.
ps -fu UserID UserID가 소유한 모든 프로세스를 프로세스 ID, 최근 CPU 사용, 총 CPU 사용, 프로세스를 시작한 명령(매개변수 포함)과 함께 나열합니다.

지금 CPU 시간을 가장 많이 쓰는 사용자를 알아내려면 다음을 입력할 수 있습니다.

text
ps -ef | egrep -v "STIME|$LOGNAME" | sort +3 -r | head -n 15

이 명령은 자기 소유가 아닌 프로세스 가운데 CPU를 가장 많이 쓰는 15개를 내림차순으로 나열합니다.

더 특수한 용도로는 다음 두 표가 플래그의 효과를 요약해 ps 플래그 고르기를 쉽게 해 줍니다.

프로세스 지정 플래그

나열할 프로세스 프로세스 지정 플래그
모든 프로세스 -A, g
프로세스 그룹 리더가 아니고 터미널과 연결되지 않은 프로세스 -a
프로세스 그룹 리더가 아닌 프로세스 -d
커널 프로세스가 아닌 프로세스 -e
지정한 프로세스 그룹의 구성원 -G, -g
커널 프로세스 -k
프로세스 번호 목록에 지정한 프로세스 -p
목록의 tty와 연결된 프로세스 -t(tty n개), t(tty 1개)
지정한 사용자의 프로세스 -U, -u
터미널이 있는 프로세스 a
tty와 연결되지 않은 프로세스 x

열 선택 플래그와 열 설명

열 내용 표시하는 플래그
PID 프로세스 ID 모두
TTY 프로세스와 연결된 터미널이나 의사 터미널 모두
TIME 사용한 누적 CPU 시간(분과 초) 모두
CMD 프로세스가 실행 중인 명령 모두
USER 프로세스가 속한 사용자의 로그인 이름 -f, u
UID 프로세스가 속한 사용자의 숫자 사용자 ID -l, -U -u, l
PPID 이 프로세스의 부모 프로세스 ID -f, -l, l
C 최근 사용한 CPU 시간 -f, -l, l
STIME 프로세스 시작 시각(24시간 안이면). 아니면 시작 날짜 -f, u
F 프로세스에 연결된 플래그를 나타내는 8자리 16진 값(ps 명령의 자세한 설명 참고) -l
S/STAT 프로세스 상태(ps 명령의 자세한 설명 참고) -l, Default2, e, l, s, u, v
PRI 프로세스의 현재 우선순위 값 -l, l
NI/NICE 프로세스의 nice 값 -l, l
ADDR 프로세스 스택의 세그먼트 번호 -l, l
SIZE (-v 플래그) 프로세스 데이터 구역의 가상 크기(KB) u
SZ (-l과 l 플래그) 프로세스 코어 이미지의 크기(KB) -f, e, s(표 그대로)
WCHAN 프로세스가 기다리는 이벤트 -l, l
RSS 메모리에 있는 작업 세그먼트와 코드 세그먼트 페이지 수의 합에 4를 곱한 값 l, u, v
SSIZ 커널 스택 크기 s
%CPU 프로세스가 시작한 뒤 CPU를 쓴 시간의 백분율 u, v
%MEM 명목상 프로세스가 쓰는 실제 메모리의 백분율. 다른 메모리 통계와는 맞지 않습니다 u, v
PGIN 페이지 부재로 생긴 페이지 인 수. 모든 I/O가 페이지 부재로 분류되므로 사실상 I/O 양의 척도입니다 v
LIM 늘 xx v
TSIZ 실행 파일 텍스트 구역의 크기 v
TRS 코드 세그먼트 페이지 수에 4를 곱한 값 v
Environment 프로세스의 모든 환경 변수 값(명령 뒤에 표시) e

ps에 플래그를 주지 않거나 마이너스 기호로 시작하는 프로세스 지정 플래그를 주면 Default1 열이 표시됩니다. 마이너스로 시작하지 않는 프로세스 지정 플래그를 주면 Default2 열이 표시됩니다. -u나 -U 플래그는 프로세스 지정 플래그이자 열 선택 플래그입니다.

영어 원문

Process monitoring

You, as the system administrator, can manage processes.

The ps command is the primary tool for observing the processes in the system. Most of the flags of the

ps command fall into one of two categories

  • Flags that specify which types of processes to include in the output

  • Flags that specify which attributes of those processes are to be displayed

The most widely useful variants of ps for system-management purposes are:

  • ps -ef — Lists all nonkernel processes, with the userid, process ID, recent CPU usage, total CPU usage, and the command that started the process (including its parameters).
  • ps -fu UserID — Lists all of the processes owned by UserID, with the process ID, recent CPU usage, total CPU usage, and the command that started the process (including its parameters).

To identify the current heaviest users of CPU time, you could enter:

text
ps -ef | egrep -v "STIME|$LOGNAME" | sort +3 -r | head -n 15

This command lists, in descending order, the 15 most CPU-intensive processes other than those owned by you.

For more specialized uses, the following two tables are intended to simplify the task of choosing ps flags by summarizing the effects of the flags.

-A -a -d -e -G -g -k -p -t -U -u a g t x
All processes Y - - - - - - - - - Y - -
Not processes
group leaders
and not
associated
with a
terminal
- Y - - - - - - - - - - -

Not process group leaders - - Y - - - - - - - - - -

Not kernel processes - - - Y - - - - - - - - -

Members of specified-process groups - - - - Y - - - - - - - -

Kernel processes - - - - - Y - - - - - - -

Those specified in process number list - - - - - - Y - - - - - -

Those associated with tty(s) in the list - - - - - - - Y (n ttys) - - - Y (1 tty) -

Specified user processes - - - - - - - - Y - - - -

Processes with terminals - - - - - - - - - Y - - -

Not associated with a tty - - - - - - - - - - - - Y

Default1 -f -l
-U
-u Default2 e l s u v
PID Y Y Y Y Y Y Y Y Y Y
TTY Y Y Y Y Y Y Y Y Y Y
TIME Y Y Y Y Y Y Y Y Y Y
CMD Y Y Y Y Y Y Y Y Y Y
USER - Y - - - - - - Y -
UID - - Y Y - - Y - - -
PPID - Y Y - - - Y - - -
C - Y Y - - - Y - - -
STIME - Y - - - - - - Y -
F - - Y - - - - - - -
S/STAT - - Y - Y Y Y Y Y Y
PIR - - Y - - - Y - - -
NI/NICE - - Y - - - Y - - -
ADDR - - Y - - - Y - - -
SIZE - - - - - - - - Y -
SZ - Y - - - Y - Y - -
WCHAN - - Y - - - Y - - -
RSS - - - - - - Y - Y Y
SSIZ - - - - - - - Y - -
%CPU - - - - - - - - Y Y
%MEM - - - - - - - - Y Y
PGIN - - - - - - - - - Y
LIM - - - - - - - - - Y
TSIZ - - - - - - - - - Y
TRS - - - - - - - - - Y
Environment (following the command) - - - - - Y - - - -

If ps is given with no flags or with a process-specifying flag that begins with a minus sign, the columns displayed are those shown for Default1. If the command is given with a process-specifying flag that does not begin with minus, Default2 columns are displayed. The -u or -U flag is both a process-specifying and column-selecting flag.

The following are brief descriptions of the contents of the columns:

  • PID — Process ID
  • TTY — Terminal or pseudo-terminal associated with the process
  • TIME — Cumulative CPU time consumed, in minutes and seconds
  • CMD — Command the process is running
  • USER — Login name of the user to whom the process belongs
  • UID — Numeric user ID of the user to whom the process belongs
  • PPID — ID of the parent process of this process
  • C — Recently used CPU time
  • STIME — Time the process started, if less than 24 hours. Otherwise the date the process is started
  • F — Eight-character hexadecimal value describing the flags associated with the process (see the detailed description of the ps command)
  • S/STAT — Status of the process (see the detailed description of the ps command)
  • PRI — Current priority value of the process
  • NI/NICE — Nice value for the process
  • ADDR — Segment number of the process stack
  • SIZE — (-v flag) The virtual size of the data section of the process (in kilobytes)
  • SZ — (-l and l flags) The size in kilobytes of the core image of the process.
  • WCHAN — Event on which the process is waiting
  • RSS — Sum of the numbers of working-segment and code-segment pages in memory times 4
  • SSIZ — Size of the kernel stack
  • %CPU — Percentage of time since the process started that it was using the CPU
  • %MEM — Nominally, the percentage of real memory being used by the process, this measure does not correlate with any other memory statistics
  • PGIN — Number of page ins caused by page faults. Since all I/O is classified as page faults, this is basically a measure of I/O volume
  • LIM — Always xx
  • TSIZ — Size of the text section of the executable file
  • TRS — Number of code-segment pages times 4
  • Environment — Value of all the environment variables for the process

프로세스 우선순위 바꾸기

기본적으로 CPU 시간을 너무 많이 쓰는 프로세스를 찾았다면 renice 명령으로 nice 값을 올려 실효 우선순위를 낮출 수 있습니다.

예:

text
renice +5 ProcID

ProcID 프로세스의 nice 값은 포그라운드 프로세스의 보통 값 20에서 25로 올라갑니다. ProcID 프로세스의 nice 값을 20으로 되돌리려면 root 권한이 있어야 합니다. 다음을 입력합니다.

text
renice -5 ProcID
영어 원문

Process priority alteration

Basically, if you have identified a process that is using too much CPU time, you can reduce its effective priority by increasing its nice value with the renice command.

For example:

text
renice +5 ProcID

The nice value of the ProcID's would increase process from the normal 20 of a foreground process to 25. You must have root authority to reset the process ProcID's nice value to 20. Type:

text
renice -5 ProcID

프로세스 종료

보통 kill 명령으로 프로세스를 끝냅니다.

kill 명령은 지정한 프로세스에 신호를 보냅니다. 신호 종류와 프로세스에서 실행 중인 프로그램의 성격에 따라 프로세스가 끝나거나 계속 실행될 수 있습니다. 보내는 신호는 다음과 같습니다.

신호 설명
SIGTERM (신호 15) 프로그램에 끝내라고 요청합니다. 프로그램에 실제로 응용 프로그램을 끝내지 않는 SIGTERM 신호 처리기가 있으면 이 kill은 효과가 없을 수 있습니다. kill이 보내는 기본 신호입니다.
SIGKILL (신호 9) 프로세스를 즉시 죽이라는 지시입니다. 이 신호는 잡거나 무시할 수 없습니다.

보통 SIGKILL보다 SIGTERM을 보내는 것이 낫습니다. 프로그램에 SIGTERM 처리기가 있으면 정리하고 질서 있게 끝낼 수 있습니다. 다음을 입력합니다.

text
kill -term ProcessID

(-term은 생략할 수 있습니다.) 프로세스가 SIGTERM에 응답하지 않으면 다음을 입력합니다.

text
kill -kill ProcessID

프로세스 테이블에서 좀비라고도 하는 defunct 프로세스가 가끔 보일 수 있습니다. 이 프로세스는 더 이상 실행되지 않고 시스템 공간도 할당되지 않았지만 PID 번호는 그대로 가지고 있습니다. 좀비 프로세스는 CMD 열에 <defunct>로 표시되므로 프로세스 테이블에서 알아볼 수 있습니다. 예:

text
UID   PID  PPID   C    STIME    TTY  TIME CMD
                            .
                            .
                            .
 lee 22392 20682   0   Jul 10      -  0:05 xclock
 lee 22536 21188   0   Jul 10  pts/0  0:00 /bin/ksh
 lee 22918 24334   0   Jul 10  pts/1  0:00 /bin/ksh
 lee 23526 22536  22                  0:00 <defunct>
 lee 24334 20682   0   Jul 10      ?  0:00 aixterm
 lee 24700     1   0   Jul 16      ?  0:00 aixterm
root 25394 26792   2   Jul 16  pts/2  0:00 ksh
 lee 26070 24700   0   Jul 16  pts/3  0:00 /bin/ksh
 lee 26792 20082   0   Jul 10  pts/2  0:00 /bin/ksh
root 27024 25394   2 17:10:44  pts/2  0:00 ps -ef

좀비 프로세스는 부모 프로세스가 죽거나 시스템을 종료하고 다시 시작할 때까지 프로세스 테이블에 남아 있습니다. 앞 예에서 부모 프로세스(PPID)는 ksh 명령입니다. Korn 셸을 끝내면 defunct 프로세스가 프로세스 테이블에서 지워집니다.

응용 프로그램이 자식 프로세스를 여러 개 fork하고 끝내지 않아 이런 defunct 프로세스가 프로세스 테이블에 쌓이기도 합니다. 이것이 문제가 되면 가장 간단한 해결책은 응용 프로그램의 sigaction 서브루틴이 SIGCHLD 신호를 무시하도록 고치는 것입니다.

관련 정보

  • sigaction 명령
영어 원문

Process termination

Normally, you use the kill command to end a process.

The kill command sends a signal to the designated process. Depending on the type of signal and the nature of the program that is running in the process, the process might end or might keep running. The signals you send are:

  • SIGTERM — (signal 15) is a request to the program to terminate. If the program has a signal handler for SIGTERM that does not actually terminate the application, this kill may have no effect. This is the default signal sent by kill.
  • SIGKILL — (signal 9) is a directive to kill the process immediately. This signal cannot be caught or ignored.

It is typically better to issue SIGTERM rather than SIGKILL. If the program has a handler for SIGTERM, it can clean up and terminate in an orderly fashion. Type:

text
kill -term ProcessID

(The -term could be omitted.) If the process does not respond to the SIGTERM, type:

text
kill -kill ProcessID

You might notice occasional defunct processes, also called zombies, in your process table. These processes are no longer executing, have no system space allocated, but still retain their PID number. You can recognize a zombie process in the process table because it displays <defunct> in the CMD column. For example:

(14줄짜리 예는 위 한글 본문에 그대로 실었습니다.)

Zombie processes continue to exist in the process table until the parent process dies or the system is shut down and restarted. In the example shown above, the parent process (PPID) is the ksh command. When the Korn shell is exited, the defunct process is removed from the process table.

Sometimes a number of these defunct processes collect in your process table because an application has forked several child processes and has not exited. If this becomes a problem, the simplest solution is to modify the application so its sigaction subroutine ignores the SIGCHLD signal.

Related information

sigaction command

프로세스 바인딩과 해제

프로세스를 프로세서에 바인딩하거나, 이전에 바인딩한 프로세스를 해제할 수 있습니다.

자기 소유가 아닌 프로세스를 바인딩하거나 해제하려면 root 사용자 권한이 있어야 합니다.

다중 프로세서 시스템에서는 다음에서 프로세스를 프로세서에 바인딩하거나 이전에 바인딩한 프로세스를 해제할 수 있습니다.

  • Web-based System Manager
  • SMIT
  • 명령행

참고: 프로세스를 프로세서에 바인딩하면 (하드웨어 캐시 부재가 줄어) 바인딩한 프로세스의 성능이 좋아질 수 있지만, 이 기능을 지나치게 쓰면 일부 프로세서는 과부하가 걸리고 다른 프로세서는 놀게 됩니다. 그 결과 생긴 병목이 전체 처리량과 성능을 떨어뜨릴 수 있습니다. 평소에는 운영 체제가 프로세스를 프로세서에 자동으로 배정해 모든 프로세서에 시스템 부하를 나누게 두는 것이 낫습니다. 프로세서 하나에서 실행해 이득을 볼 수 있다고 아는 프로세스만 바인딩합니다.

작업 SMIT 빠른 경로 명령이나 파일
프로세스 바인딩 smit bindproc bindprocessor(-q로 쓸 수 있는 프로세서 확인)
프로세스 바인딩 해제 smit ubindproc bindprocessor -u

멈추거나 원치 않는 프로세스 고치기

멈추거나 원치 않는 프로세스는 터미널에 문제를 일으킬 수 있습니다. 어떤 문제는 화면에 원인을 짐작할 정보를 담은 메시지를 냅니다.

다음 절차를 하려면 두 번째 터미널, 모뎀, 네트워크 로그인 가운데 하나가 있어야 합니다. 아무것도 없으면 기계를 재부팅해 터미널 문제를 고칩니다.

터미널 문제에 맞는 절차를 고릅니다.

프로세스가 차지한 터미널 풀기

멈추거나 원치 않는 프로세스를 멈출 수 있습니다.

다음과 같이 멈추거나 원치 않는 프로세스를 찾아 멈춥니다.

  1. 다음 ps 명령으로 화면에서 실행 중인 활성 프로세스를 알아냅니다.
text
ps -ef | pg

ps 명령은 프로세스 상태를 보여 줍니다. -e 플래그는 (커널 프로세스를 뺀) 모든 프로세스 정보를 쓰고, f 플래그는 프로세스를 만들 때의 명령 이름과 매개변수를 포함한 전체 목록을 만듭니다. pg 명령은 출력을 한 페이지씩 끊어 정보가 화면에서 빨리 밀려 나가지 않게 합니다. 의심스러운 프로세스로는 CPU나 디스크 공간 같은 시스템 자원을 지나치게 쓰는 시스템 또는 사용자 프로세스가 있습니다. sendmail, routed, lpd 같은 시스템 프로세스가 폭주하는 일이 잦습니다. CPU 사용량은 ps -u 명령으로 확인합니다. 2. who 명령으로 이 기계에서 누가 프로세스를 실행 중인지 알아냅니다.

text
who

who 명령은 지금 이 시스템에 있는 모든 사용자의 로그인 이름, 워크스테이션 이름, 로그인 날짜와 시각 같은 정보를 보여 줍니다. 3. 사용자 프로세스를 멈출지, 일시 중단할지, 우선순위를 바꿀지 정합니다.

참고: 자기 것이 아닌 프로세스를 멈추려면 root 권한이 있어야 합니다. 사용자 프로세스를 끝내거나 우선순위를 바꿨다면 프로세스 소유자에게 연락해 한 일을 설명합니다.

  • kill 명령으로 프로세스를 멈춥니다. 예:
text
kill 1883

kill 명령은 실행 중인 프로세스에 신호를 보냅니다. 프로세스를 멈추려면 프로세스 ID(PID)를 지정하며, 이 예에서는 1883입니다. 명령의 PID 번호는 ps 명령으로 알아냅니다.

  • 앰퍼샌드(&)로 프로세스를 일시 중단하고 백그라운드에서 실행합니다. 예:
text
/u/bin1/prog1 &

&는 이 프로세스를 백그라운드에서 실행하겠다는 뜻입니다. 백그라운드 프로세스에서는 셸이 명령이 끝나기를 기다리지 않고 셸 프롬프트를 돌려줍니다. 끝나는 데 몇 초 넘게 걸리는 프로세스는 명령행 끝에 &를 붙여 백그라운드에서 실행합니다. 백그라운드에서 실행 중인 작업은 일반 ps 명령에 나옵니다.

  • 다음 renice 명령으로 자원을 차지한 프로세스의 우선순위를 바꿉니다.
text
renice 20 1883

renice 명령은 실행 중인 프로세스 하나 이상의 스케줄링 우선순위를 바꿉니다. 숫자가 클수록 우선순위가 낮으며 20이 가장 낮습니다. 앞 예에서 renice는 1883번 프로세스를 가장 낮은 우선순위로 다시 스케줄합니다. 이 프로세스는 쓰이지 않는 프로세서 시간이 조금 있을 때 실행됩니다.

화면 메시지에 대응하기

이 절차로 화면 메시지에 대응하고 복구합니다.

  1. DISPLAY 환경 변수가 올바르게 설정됐는지 확인합니다. 다음 방법 가운데 하나로 DISPLAY 환경을 확인합니다.
    • setsenv 명령으로 환경 변수를 봅니다.
text
setsenv

setsenv 명령은 로그인할 때의 보호 상태 환경을 보여 줍니다.

 DISPLAY 변수가 설정됐는지 확인합니다. 다음 예에서는 DISPLAY 변수가 나오지 않으므로 DISPLAY 변수가 특정 값으로 설정되지 않았다는 뜻입니다.
text
SYSENVIRON:
NAME=casey
TTY=/dev/pts/5
LOGNAME=casey
LOGIN=casey

또는

  • DISPLAY 변수 값을 바꿉니다. 예를 들어 bastet이라는 기계의 터미널 0으로 설정하려면 다음을 입력합니다.
text
DISPLAY=bastet:0
export DISPLAY

따로 설정하지 않으면 DISPLAY 환경 변수의 기본값은 unix:0(콘솔)입니다. 변수 값은 name:number 형식이며, name은 특정 기계의 호스트 이름, number는 그 시스템의 X 서버 번호입니다. 2. 다음 stty 명령으로 터미널을 기본값으로 재설정합니다.

text
stty sane

stty sane 명령은 터미널 드라이버의 "정상 상태"를 되돌립니다. 이 명령은 /etc/termcap 파일(있으면 /usr/share/lib/terminfo)에서 알맞은 터미널 재설정 코드를 출력합니다. 3. Return 키가 제대로 동작하지 않으면 다음을 입력해 재설정합니다.

text
^J stty sane ^J

^J는 Ctrl-J 키 조합을 나타냅니다.

환경 변수 RT_MPC와 RT_GRQ로 여러 큐 실행하기

실행 큐를 여럿 쓰면 스레드의 프로세서 친화성이 높아지지만, 이 효과를 상쇄하고 싶은 특수한 상황이 있습니다.

실행 큐가 하나뿐이면, 실행 중인 다른 스레드(깨우는 스레드)가 깨운 스레드(깨어나는 스레드)는 보통 깨우는 스레드가 실행되던 CPU를 바로 쓸 수 있습니다. 실행 큐가 여럿이면 깨어나는 스레드가 다른 CPU의 실행 큐에 있을 수 있는데, 그 CPU는 다음 스케줄링 결정 때까지 깨어난 스레드를 알아채지 못합니다. 그러면 최대 10ms까지 늦어질 수 있습니다.

이것은 이 운영 체제의 이전 릴리스에서 bindprocessor 옵션을 썼을 때 생길 수 있었던 상황과 비슷합니다. 모든 CPU가 늘 바쁘고 서로 의존하는 스레드가 여럿 깨어난다면 두 가지 방법이 있습니다.

  • 첫째 방법은 실행 큐 하나를 쓰는 것으로, 환경 변수 RT_GRQ=ON을 설정해 선택한 바인딩되지 않은 스레드를 전역 실행 큐에서 디스패치하게 합니다.
  • 아니면 실시간 커널 옵션(bosdebug -R on 명령을 입력한 뒤 bosboot)과 선택한 프로세스에 RT_MPC=ON 환경 변수를 쓸 수 있습니다. 조정을 시도할 때마다 그 영향을 면밀히 감시하도록 시스템 성능 로그를 유지하는 것이 꼭 필요합니다.
영어 원문

Binding or unbinding a process

You can bind a process to a processor or unbind a previously bound process.

You must have root user authority to bind or unbind a process you do not own.

On multiprocessor systems, you can bind a process to a processor or unbind a previously bound process from:

  • Web-based System Manager

  • SMIT

  • command line

Note: While binding a process to a processor might lead to improved performance for the bound process (by decreasing hardware-cache misses), overuse of this facility could cause individual processors to become overloaded while other processors are underused. The resulting bottlenecks could reduce overall throughput and performance. During normal operations, it is better to let the operating system assign processes to processors automatically, distributing system load across all processors. Bind only those processes that you know can benefit from being run on a single processor. Task SMIT Fast Path Command or File Binding a Process smit bindproc bindprocessor -q Unbinding a Process smit ubindproc bindprocessor -u

Fixes for stalled or unwanted processes

Stalled or unwanted processes can cause problems with your terminal. Some problems produce messages on your screen that give information about possible causes.

To perform the following procedures, you must have either a second terminal, a modem, or a network login. If you do not have any of these, fix the terminal problem by rebooting your machine.

Choose the appropriate procedure for fixing your terminal problem:

Freeing a terminal taken over by processes:

You can stop stalled or unwanted process.

Identify and stop stalled or unwanted processes by doing the following:

  1. Determine the active processes running on the screen by typing the following ps command:
text
ps -ef | pg

The ps command shows the process status. The -e flag writes information about all processes (except kernel processes), and the f flag generates a full listing of processes including what the command name and parameters were when the process was created. The pg command limits output to a single page at a time, so information does not quickly scroll off the screen. Suspicious processes include system or user processes that use up excessive amounts of a system resource such as CPU or disk space. System processes such as sendmail, routed, and lpd frequently become runaways. Use the ps -u command to check CPU usage.

  1. Determine who is running processes on this machine by using the who command:
text
who

The who command displays information about all users currently on this system, such as login name, workstation name, date, and time of login.

  1. Determine if you need to stop, suspend, or change the priority of a user process.

Note: You must have root authority to stop processes other than your own. If you terminate or change the priority of a user process, contact the process owner and explain what you have done.

  • Stop the process using the kill command. For example:
text
kill 1883

The kill command sends a signal to a running process. To stop a process, specify the process ID (PID), which is 1883 in this example. Use the ps command to determine the PID number of commands.

  • Suspend the process and run it in the background by using the ampersand (&). For example:
text
/u/bin1/prog1 &

The & signals that you want this process to run in the background. In a background process, the shell does not wait for the command to complete before returning the shell prompt. When a process requires more than a few seconds to complete, run the command in background by typing an & at the end of the command line. Jobs running in the background appear in the normal ps command.

  • Change the priority of the processes that have taken over by using the following renice command:
text
renice 20 1883

The renice command alters the scheduling priority of one or more running processes. The higher the number, the lower the priority with 20 being the lowest priority. In the previous example, renice reschedules process number 1883 to the lowest priority. It will run when there is a small amount of unused processor time available.

Responding to screen messages:

Use this procedure to respond to and recover from screen messages.

  1. Make sure the DISPLAY environment variable is set correctly. Use either of the following methods to check the DISPLAY environment:
  • Use the setsenv command to display the environment variables.
text
setsenv

The setsenv command displays the protected state environment when you logged in.

Determine if the DISPLAY variable has been set. In the following example, the DISPLAY variable does not appear, which indicates that the DISPLAY variable is not set to a specific value.

text
SYSENVIRON:
NAME=casey
TTY=/dev/pts/5
LOGNAME=casey
LOGIN=casey

OR

  • Change the value of the DISPLAY variable. For example, to set it to the machine named bastet and terminal 0, enter:
text
DISPLAY=bastet:0
export DISPLAY

If not specifically set, the DISPLAY environment variable defaults to unix:0 (the console). The value of the variable is in the format name:number where name is the host name of a particular machine, and number is the X server number on the named system.

  1. Reset the terminal to its defaults using the following stty command:
text
stty sane

The stty sane command restores the “sanity” of the terminal drivers. The command outputs an appropriate terminal resetting code from the /etc/termcap file (or /usr/share/lib/terminfo if available).

  1. If the Return key does not work correctly, reset it by typing:
text
^J stty sane ^J

The ^J represents the Ctrl-J key sequence.

Running multiple queues using environment variables RT_MPC and RT_GRQ:

The use of multiple queues increases the processor affinity of threads, but there is a special situation where you might want to counteract this effect.

When there is only one run queue, a thread that has been awakened (the waking thread) by another running thread (the waker thread) would normally be able to use the CPU immediately on which the waker thread was running. With multiple run queues, the waking thread may be on the run queue of another CPU which cannot notice the waking thread until the next scheduling decision. This may result in up to a 10 ms delay.

This is similar to scenarios in earlier releases of this operating system which might have occurred using the bindprocessor option. If all CPUs are constantly busy, and there are a number of interdependent threads waking up, there are two options available.

  • The first option, which uses one run queue, is to set the environment variable RT_GRQ=ON which forces unbound selected threads to be dispatched off the global run queue.

  • Alternatively, users can choose the real time kernel option (type the command bosdebug -R on and then bosboot) and the RT_MPC=ON environment variable for selected processes. It is essential to maintain a performance log of your systems to closely monitor the impact of any tuning you attempt.