- 1) nohup
- https://www.devkuma.com/docs/linux/nohup
- nohup python main.py 아큐먼트 > /dev/null 2>&1 &
- 문제)
- iTerm 으로 mac m1 서버환경에 SSH 접속 하여 zsh 에서 했는데...
- "nohup: can't detach from console: Undefined error: 0" 식의 오류가 뜨면서 안됨...
- https://community.jamf.com/t5/jamf-pro/when-can-a-script-fork-a-background-process/m-p/248144
- 2) screen
- 3) tmux
- https://pebpung.github.io/engineering/2022/04/24/Tmux.html
- https://jh-bk.tistory.com/11
- 문제)
- 음... local 에서 -{ssh}-> remote 으로 접속.
- iTerm zsh 에서 새로운 tmux session 생성 및 attach.
- 작업후~ (ctrl+b , d) detached -> local 으로 돌아옴 ?!?!?!
- 4) disown
- https://en.wikipedia.org/wiki/Disown_(Unix)
- 'Unix shells', 'ksh', 'bash', 'fish-shell', 'zsh' 에서 빌트인 커맨드로 제공이 됨.
- (로그아웃 등으로) 부모쉘 에서 SIGHUP 을 받더라도 -> 해당 job 에 전달이 되지 않도록 표식!
- 그러게 표시된 job table 에서 해당 job 을 다시 뺌!
- zsh 명령어 : https://zsh.sourceforge.io/Doc/Release/Shell-Builtin-Commands.html
- 예) ssh 접속 -> python main.py 아큐먼트 > /dev/null 2>&1 & -> exit -> "zsh: you have running jobs." 오류
- https://stackoverflow.com/questions/19302913/exit-zsh-but-leave-running-jobs-open
- nohup python main.py 아큐먼트 > /dev/null 2>&1 & disown
- & : 서프터미널 백그라운드에서 동작하도록 함
- disown : 최신 job 이~, 쉘로 부터의 SIGHUP 이 자식 프로세스에 안가도록 함
- nohup : 해당 cmd 가~ 쉘로 부터의 SIGHUP 을 무시하도록 함
- https://phoenixnap.com/kb/disown-command-linux
- https://velog.io/@jakeseo_me/nohup-disown-는-언제-어떻게-써야될까-9fjv7q9bz8
- 문제)
- 하필! 파이썬 차원에서 멀티프로세싱을 할때... 'spawn' 으로 하면 안된다 ?!?!?!
- ctx = multiprocessing.get_context('fork') 으로 바꾸니 됨.
- ...
- Windows CMD
- pythonw -u -X utf8 main.py 아규먼트 > NUL 2>&1
- tasklist | findstr "py"
- taskkill /F /T /PID 12345
- PowerShell
- Get-Content test.log -Wait -Tail 10