다음 시나리오를 고려하십시오.
tail.sh :
#!/bin/bash
tail -f test.txt
invoke.sh :
#!/bin/bash
nohup ./tail.sh &
invoke_explicitredirect.sh :
#!/bin/bash
nohup ./tail.sh > out.log &
터미널에서 둘 다 실행하면 동일한 효과가 있습니다.
./tail.sh
tail
이 터미널에 나타나지 않습니다.그러나 ssh
(예 :)를 사용하여 실행할 때 ssh <user>@<hostname> "<script>"
:
invoke_explicitredirect.sh
제어권을 반환 ssh
하고 종료합니다.invoke.sh
내가 보낼 때까지 SIGINT
man nohup
국가 그 nohup
것이다 'nohup.out은'가능하면 자동으로 리디렉션 출력 :
If standard output is a terminal, append output to 'nohup.out' if possible, '$HOME/nohup.out' otherwise.
nohup
추가를 허용하는 것과 nohup.out
출력을 명시 적으로 리디렉션하는 것의 차이점은 무엇입니까 ?
ssh를 통해 원격으로 명령을 실행할 때 표준 출력은 터미널이 아닙니다. 두 명령 모두에서 동일한 동작을 얻으려면 -t
with 옵션을 사용하십시오 ssh
.
ssh 및 nohup에 대한 자세한 내용 : http://snailbook.com/faq/background-jobs.auto.html (위키 페이지에서 가져옴 : https://en.wikipedia.org/wiki/Nohup )
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다