Linuxã³ãã³ããããã¯ã°ã©ã¦ã³ãã§å®è¡ãã
ãªã¢ã¼ããµã¼ãã¼ä¸ã§ä½æ¥ããã¦ããæãsshãããã°ã¢ã¦ããã¦ãå¦çãç¶ç¶ãã¦æ¬²ããå ´åãããªãã¹(ä¼ç¤¾ãç 究室ã®GPUãµã¼ãã¼ã§æ©æ¢°å¦ç¿ã¢ãã«ãå¦ç¿ãããå ´åãªã©)ããããªæã«ä½¿ãã便å©ã³ãã³ãã®åå¿é²ãæ¹æ³ã¯ä¸»ã«ï¼ã¤ããã¾ã(ä»ã«ããããã)ã
- tmuxã使ãæ¹æ³
- screenã使ãæ¹æ³
- nohupã使ãæ¹æ³
3ã®nohupã使ãæ¹æ³ãä¸çªæ軽ã ã¨æãã¾ããä¼ç¤¾ãªã©ã®ãµã¼ãã¼ã使ãæã権éå¨ãã®åé¡ã§tmuxãscreenãã¤ã³ã¹ãã¼ã«ã§ããªãå ´åãããã¾ããnohupã§ããã°ãããªæã«ãå®è¡å¯è½ãªã®ãå©ç¹ã§ããï¼ã¤ï¼ã¤å ·ä½çãªæ¹æ³ãè¦ã¦ããã¾ãããã
tmuxã使ãæ¹æ³
tmuxã¨ã¯
tmuxã¨ã¯ï¼ã¤ã®ç«¯æ«ãè¤æ°ã«åå²ãããã¨ãåºæ¥ããã¼ã«ã§ãã
ã¤ã³ã¹ãã¼ã«ã¯ã
$ sudo apt install tmux
ããã¯ã°ã©ã¦ã³ãå®è¡
tmuxã¯sessionã¨ããåä½ã§ç®¡çããã¦ãã¦ãsessionã¯ã³ã³ã½ã¼ã«ããåãé¢ãã¦ããã¯ã°ã©ã¦ã³ãã«æ®ãã¦ãããã¨ãåºæ¥ã¾ãã
tmuxãç«ã¡ä¸ããã¨åæã«sessionãä½æããã¾ãã
$ tmux
sessionãã³ã³ã½ã¼ã«ããåãé¢ãã«ã¯ãdetachã¨attachã使ãã¾ãã
detachã§é¢è±ããattachã§å¾©å¸°ãããã¨ãåºæ¥ã¾ãã
detach
$ [ctrl b] + d
attach
$ tmux a
sessionã®ç¢ºèª
$ tmux ls
detachã¨attachã¯tmuxã®ä¾¿å©æ©è½ã®ï¼ã¤ã§ããã£ã¨è²ããªäºãåºæ¥ããã¤ã³ãã©ã¨ã³ã¸ãã¢ã¯tmuxã好ãã§ä½¿ããããã§ãã
screenã使ãæ¹æ³
screenã¨ã¯
screenã使ãã¨ï¼ã¤ã®ç«¯æ«ä¸ã§è¤æ°ã®ä»®æ³ç«¯æ«ãèµ·åããäºãåºæ¥ã¾ããtmuxã¨screenã«ã¯ããããåªããç¹ããããããããæ£ç´ãã¾ãéããåããã¾ããã§ãããtmuxã®æ¹ãå¤å°è»½éãããã§ãã ã¤ã³ã¹ãã¼ã«ã¯ã
$ sudo apt install screen
ããã¯ã°ã©ã¦ã³ãå®è¡
tmuxã¨åãããã«ãsessionãèµ·åãã¦detachããäºã§ããã¯ã°ã©ã¦ã³ãã§ã³ãã³ããå®è¡ãã¦ããäºãåºæ¥ã¾ãã
sessionã®èµ·å
$ screen
detach
$ [ctrl a] + d
attach
$ screen -r
sessionã®ç¢ºèª
$ screen -ls
tmuxã¨åããä»ã«ã便å©æ©è½ãããã
nohupã使ãæ¹æ³
nohupã¨ã¯
nohupã¨ã¯linuxã®æ¨æºã³ãã³ãã§ããããã°ã¢ã¦ãå¾ã«ãããã¯ã°ã©ã³ãã§ã³ãã³ããå®è¡ãã¦ããäºãåºæ¥ã¾ããä¸è¿°ã®tmuxãscreenãªã©ã¨éãç¹ã¯ã¤ã³ã¹ãã¼ã«ãäºåæºåãå¿
è¦ãªãäºã§ããä¼ç¤¾ãªã©ã®å
±ç¨ãµã¼ãã¼ã§åæã«sudo apt install
ãåºæ¥ãªãæã«ãnohup
ã§ããã°ä½¿ãäºãã§ãã¾ãã
ããã¯ã°ã©ã¦ã³ãå®è¡
ããã¯ã°ã©ã¦ã³ãã§ã³ãã³ããå®è¡
$ nohup ã³ãã³ã &
ã³ãã³ããnohup
ã¨&
ã§æãã ãã§ããã¯ã°ã©ã¦ã³ãå®è¡ãã§ãããåºåã¯ããã©ã«ãã§ã¯ãnohup.out
ã«æ¸ãåºããã¾ããåºåå
ãå¤æ´ãããå ´åã¯ã
$ nohup ã³ãã³ã > åºåå $
ã¨ããã
ã¾ããé çªã«è¤æ°ã³ãã³ããå®è¡ãããå ´åã¯ã
$ nohup -sh c 'ã³ãã³ã1 ; ã³ãã³ã2' &
ã¨ãããé常ã«ç°¡åã§ãã
ã¾ã¨ã
Linuxã§ã³ãã³ããããã¯ã°ã©ã³ãå®è¡ããã«ã¯ã
1. tmux
2. screen
3. nohup
ã®ï¼ã¤ã®æ¹æ³ãããã
ç®çãã³ãã³ãã®ããã¯ã°ã©ã¦ã³ãå®è¡ã®ã¿ã®å ´åãnohup
ã使ãã®ããã£ã¨ãæ軽ã§ããããã§ãã