Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a script that calls a number of other install scripts

./ 2>&1 | tee script1.log<br>
./ 2>&1 | tee script2.log<br>
./ 2>&1 | tee script3.log<br>

They all look ok till the last one which does a call to a custom init script. This init script runs the daemon as /usr/local/daemon &. i.e. puts it into the background.

Combine this with using tee and the main script hangs as the final tee never exits.

The init script is a .NET app running under mono so I've very little control over it. If I don't use tee then it all looks ok. Running the last command from the command line has the same effect.

If anyone can suggest a way of making the script exit cleanly I'd be grateful. For now I've moved the call to the init script out of script3 into the parent script and it works fine but of course it's not logged.

share|improve this question

This may not be the best answer, but you can do tee script3.log & (with an ampersand in the end), so that the script can terminate without hanging. It does have the side effect of terminating the script before terminating

share|improve this answer

Tee will not exit gracefully until the stdout of both the parent and child process gets closed. Try redirecting the stdout of the daemon

/usr/local/daemon > /dev/null 2>&1 &
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .