Reputation: 4544
When I run this command netstat -t 1 -i 2>&1 > $NETStat_OUT_FILE &
inside a script , the output of netstat does not get redirected to the file.. Could any one find a solution for this ?
Upvotes: 1
Views: 989
Reputation: 23866
In order to solve the timing problem you can use wait:
netstat ... &
p=$!
do something else ...
wait $p
Upvotes: 0
Reputation: 360143
You need to redirect stdout first, then stderr.
netstat -t 1 -i > $NETStat_OUT_FILE 2>&1 &
Upvotes: 1