Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

./script1.sh 2>&1 | tee script1.log<br>
./script2.sh 2>&1 | tee script2.log<br>
./script3.sh 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

2 Answers 2

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 script3.sh.

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.