OS, Container/Operating System

Process

JunMoo 2020. 10. 3. 18:28

Process

n. In computing, a process is the instance of a computer program that is being executed by one or many threads. It contains the program code and its activity. Depending on the operating system (OS), a process may be made up of multiple threads of execution that execute instructions concurrently.(from Wikipedia)

i.e. 하드디스크에 저장된 실행 코드(프로그램)가 메모리에 로딩되어 활성화된 것.(from 이것이 우분투 리눅스다 p.243)

Program(Deactivated) + Memory load = Process(Activated)

 

Process related commands

  • ps(Process Snapshot)
    현재 process의 상태를 확인하는 명령어. 주로 사용되는 조합은 "ps -ef | grep 찾을단어"이다.
    자세한 옵션은 링크 참조.
  • lsof(List of Open Files)
    ps와 비슷하나 더많은 정보를 보여주는 명령어. 주로 "lsof -i tc[:포트번호"로 조회한다.

tomcat 컨테이너를 띄우고 80포트로 서비스중이 때 조회한 상황.

  • kill
    활성화된 process를 강제 종료하는 명령어. '-9' 옵션을 함께 사용하면, 무조건 강제 종료시킨다.
    자세한 옵션은 링크 참조.(killall이라는 명령어도 있으나 모든 프로세스를 강제종료시키므로, 실무에서 사용금지)

 root의 bash shell을 종료해서 강제로 나가지는 상황.

  • pstree
    process간 종속도를 트리형태로 보여준다.
    자세한 옵션은 링크 참조.

sshd 아래에 bash와 sudo su, bash 그리고 pstree가 있다!

  • top(Display and Update TOP CPU Processes)
    실시간으로 현재 작업중인 process와 cpu, ram 사용률등 다양한 정보를 보여준다. 실무에서 서버내 알 수 없는 원인의 문제를 찾을 떄 자주 사용함.

Memory나 CPU를 많이 소모하는 process를 파악할 때 가장 먼저 top을 써보자!

  • nice(The nice command)
    Priority를 지정하는 명령어. 기본적으로 10의 우선순위를 부여하며 nice 없이 프로세스를 실행할 경우 우선순위는 0이다.
  • renice(The renice command)
    Priority를 수정하는 명령어. 이미 지정된 우선순위를 수정할 수 있다.

Process related concepts.

  • Foreground Process
    사용자와 상호작용하는 Process. 내 앞에서 열심히 일하고 있다!
  • Background Process
    Background에서 진행되는 Process. 나 몰래 열심히 일하고 있다!
  • Process ID
    Process들의 주민등록번호. 유일하다. 퇴사(강제 종료)시킬 때 필요하다.
  • Job ID
    background process의 순차 번호. PID와 다른 것.
  • Parent Process and Child Process
    Process 간 종속성에 따라 Parent, Child 관계를 정의. Parent process를 kill하면 child도 종료된다!

'OS, Container > Operating System' 카테고리의 다른 글

Shell Scripting(a.k.a Linux의 꽃)  (0) 2020.10.17
LVM  (0) 2020.10.03
Disk Mount/Unmount on Linux  (0) 2020.10.03
GRUB(Ubuntu)  (0) 2020.10.03
Daemon, Service  (0) 2020.10.03