Issue
I can store the output of a hive query using nohup like so:
nohup hive -i transaction_testing.hive > nohup.out 2>&1 &
My understanding is that 2>&1 redirects standard error to std out.
My question is, can I also redirect the standard in so that everything is just in one file?
A Google search shows me that in linux std in is 0.
Can I edit the piece of code above to also include the input as well as the std error in the nohup file?
E.g. suppose transactions_testing.hive contains the following:
select *
from some_table
where fruits = 'apples';
I would like to output file to contain this command at the top along with the results of the query underneath.
If 2>&1
redirects std error to std out, would 0>&1
do the same for std in? How would I combine it all into one?
nohup hive -i transaction_testing.hive > nohup.out 0>1&2>&1 &
Solution
0>&1
means that anything written to standard input will be sent to FD 1 instead. But nothing normally writes to standard input, it's only used for reading.
You can simply copy the input file to the output file, then append to it when you run the command.
cp transaction_testing.hive nohup.out
nohup hive -i transaction_testing.hive >> nohup.out 2>&1
Answered By - Barmar