Considere o seguinte cenário:
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 &
A execução de ambos em um terminal tem o mesmo efeito:
- Eu recupero o controle do terminal depois de executar
./tail.sh
- Nenhuma saída de
tail aparece no terminal
No entanto, ao executá-lo usando ssh (por exemplo, ssh <user>@<hostname> "<script>" ):
-
invoke_explicitredirect.sh retorna o controle para ssh (e termina)
-
invoke.sh trava até eu enviar um SIGINT
man nohup afirma que nohup redirecionará automaticamente a saída para 'nohup.out', se possível:
If standard output is a terminal, append output to 'nohup.out' if possible, '$HOME/nohup.out' otherwise.
Qual é a diferença entre deixar nohup anexar a nohup.out e redirecionar explicitamente a saída?