Run The Bridge

가상 터미널 종료하기 본문

Cloud/Linux

가상 터미널 종료하기

anfrhrl5555 2022. 8. 2. 20:11
728x90
반응형

 

Liunx를 사용할 때 putty, mobaXterm, SecureCRT 등 터미널 프로그램을 사용하는데

 

나는 mobaXterm를 즐겨 사용하고 있다.

 

mobaXterm에 동일 서버에 여러 개의 세션을 띄워두면 아래와 같이 w 명령어로 확인이 가능하다.

w 명령어

 

'w' 명령어로 현재 열린 세션에 어떤 명령어를 사용하고 있는지 확인할 수 있다.

 

근데 이렇게 세션을 열어두고 강제 종료된다면 어떻게 될까?

foreground로 실행

 

이렇게 세션은 하나인데, top과 watch 명령어가 계속 돌아가고 있다.

 

이럴 때 PID라도 나온다면 kill 명령어를 활용할 텐데

 

아무것도 보이지 않는다.

background로 동작중

 

이때 'ps -lt' 명령어로 pid를 확인할 수 있다.

 

man ps 명령어로 좀 더 정확하게 알 수 있다.

   t ttylist
              Select by tty.  Nearly identical to -t and --tty, but can also be used with an empty ttylist to indicate the terminal associated with ps.  Using the T option is considered cleaner than using t with an empty
              ttylist.

       -t ttylist
              Select by tty.  This selects the processes associated with the terminals given in ttylist.  Terminals (ttys, or screens for text output) can be specified in several forms: /dev/ttyS1, ttyS1, S1.  A plain "-" may
              be used to select processes not attached to any terminal.

       --tty ttylist
              Select by terminal.  Identical to -t and t.
   l      Display BSD long format.

       -l     Long format.  The -y option is often useful with this.

 

이제 가상 터미널을 종료해본다.

 

우선 top를 실행하는 가상 터미널 먼저 종료한다.(pts/0)

PID 확인

 

top 명령어를 사용하는 가상 터미널이 삭제되었다.

top 명령어 삭제

 

또 다른 방법으로는 'ps -ef ' 명령어를 사용하는 방법이다.

 

어차피 같은 서버에서 프로세스로 동작하고 있기 때문에 확인이 가능하다.

 

마찬가지로 kill 명령어로 해당 프로세스를 죽여주면 된다.

watch 프로세스 제거

 

이렇게 프로세스를 잡아먹는 top, watch 명령어를 삭제해보았다.

깔끔 ~

 

작업하다가 인터넷이 간헐적으로 끊기면 터미널이 모두 날아가는데

 

그때마다 재접속하고 'w' 명령어로 확인해보면 가상 터미널이 왕창 켜져 있어 지저분했는데

 

오늘 구글 검색을 통해서 말끔한 해결책을 알아서, 공유해본다.

 

참고: https://www.ibm.com/docs/ko/aix/7.1?topic=troubleshooting-clearing-hung-tty-port

728x90
반응형
Comments