Redirection problem

hi
i want a solution for the fallowing:
i am redirecting output from bash script in which we are running background commands like
./test.sh
contains
ls -l &
ps

when we do as
./test.sh 1> test.txt 2>&1

but test.txt not containing output as ls -l and ps.
it showing ls -l, ps and ls-l output means output of ls -l is repeating.
please give the solution to get ls -l and ps output only.

Why are you running ls -l in the background (i.e. with & on the end)? Perhaps if you remove the & you will get the output you desire.

try the rearranged command as follows.

./test.sh 2>&1 >test.txt