Answer the question
In order to leave comments, you need to log in
How to redirect the output of a script to a file and run it in the background?
Trying to combine two commands
bin/prog &
bin/prog 2>&1 >filename.log
The two obvious options don't work
bin/prog 2>&1 >filename.log &
bin/prog & 2>&1 >filename.log
Answer the question
In order to leave comments, you need to log in
bin/prog 2>&1 >filename.log
Well, this option doesn't work anyway if you wanted to redirect both stdout and stderr to filename.log. In fact, you redirected only stdout to filename.log, and stderr went to the freed stdout.
But if you write it in a working form:
or
then after the union it will work:
orbin/prog > filename.log 2>&1 &
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question