mercredi 31 décembre 2014

What is the difference between letting nohup append to 'nohup.out' and explicitly redirecting it to a file?


Consider the following scenario:


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 &


Running both in a terminal has the same effect:



  • I regain control of the terminal after running ./tail.sh

  • No output from tail appears on the terminal


However, when running it using ssh (e.g. ssh <user>@<hostname> "<script>"):



  • invoke_explicitredirect.sh returns control to ssh (and terminates)

  • invoke.sh hangs until I send a SIGINT


man nohup states that nohup will automatically redirect output to 'nohup.out' if possible:



If standard output is a terminal, append output to 'nohup.out' if possible, '$HOME/nohup.out' otherwise.


What is the difference between letting nohup append to nohup.out and explicitly redirecting the output?



Aucun commentaire:

Enregistrer un commentaire