annyoung

ssh process continuation 본문

운영체제

ssh process continuation

nopsled 2015. 10. 10. 11:03

[english]

if disconnect ssh, process will be dead. so we using linux "screen".


# nopsled@localhost:~/Documents (=`ω´=)$ screen -S test


/* now created new screen ttys is 005 */

# nopsled@localhost:~/Document (=`ω´=)/$ screen -list

There is a screen on:

        5960.test       (Attached)


/* if you want execute test.py on ssh connection forever, using & and detach it */

# nopsled@localhost:~/Documents (=`ω´=)$ python test.py &


/* detach it now */

# nopsled@localhost:~/Documents (=`ω´=)$ screen -d

[remote detached]


/* now get out screen. and working at ttsy002*/

# nopsled@localhost:~/Documents (=`ω´=)$ ps -ef | grep python

  501  6043  5962   0 10:55AM ttys005    0:05.16 python test.py

  501  6012  5767   0 10:51AM ttys002    0:00.00 grep python




if you want re attach it, using "screen -r pid" like next.


nopsled@localhost:~/Documents (=`ω´=)$ screen -list

There is a screen on:

6080.test (Detached)

1 Socket in /var/folders/4c/8lgn3z2970v0qkwn2z08twhh0000gn/T/.screen.


nopsled@localhost:~/Documents (=`ω´=)$ screen -r 6080





if you want terminate screen, using exit!

nopsled@localhost:~/Documents (=`ω´=)$ exit

[screen is terminating]

nopsled@localhost:~/Documents (=`ω´=)$







[한국어]

끊긴 ssh에서 프로세스를 계속 사용하기 위해서는 screen을 사용해야 한다.


screen -list를 이용하여 리스트를 보고 screen -r을 사용하여 attach, screen -d를 사용하여 detach를 한다.


프로세스를 실행시킨후 screen -S 하는게 아닌, screen -S를 사용하여 새로운 스크린을 만든 후 프로세스를 실행시켜야 원활히 돌아간다.

Comments