P
P
Puma Thailand2014-03-06 15:36:52
linux
Puma Thailand, 2014-03-06 15:36:52

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

3 answer(s)
A
avalak, 2014-03-06
@avalak

(./bin/prog &> filename.txt ) &

J
jcmvbkbc, 2014-03-06
@jcmvbkbc

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:
or
bin/prog > filename.log 2>&1 &

N
Nikolai Vasilchuk, 2014-03-06
@Anonym

nohup ./bin/prog > prog.log &

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question