Reputation: 15010
I have a bash script that does the following.
spinner()
{
local pid=$1
local delay=0.75
local spinstr='\|/-'
while [ "$(ps a | awk '{print $1}' | grep $pid)" ]; do
local temp=${spinstr#?}
printf " [%c] " "$spinstr"
local spinstr=$temp${spinstr%"$temp"}
sleep $delay
printf "\b\b\b\b\b\b"
done
printf " \b\b\b\b"
}
printf "Testing for timestamps,please wait..." | tee test_report.txt
(process_1 -f $FILENAME test_1 >> test_report.txt 2>&1)&
spinner $!
printf "\n"
printf "Testing for accurate seq numbers,please wait..." | tee test_report.txt
(process_2 -f $FILENAME sequence >> test_report.txt 2>&1) &
spinner $!
printf "\n";
However when I open the test_report.txt I see only the output of 'process_2'
and can't see the output of 'process_1'
I guess the question really is what happens to a the output file that contains the stdout of a background process.?
Upvotes: 0
Views: 299
Reputation: 212574
The tee test_report.txt
is overwriting it. Try tee -a test_report.txt
Upvotes: 4