使用 nohup 我还可以重定向标准吗?

Using nohup can I also redirect standard in?

我可以像这样使用 nohup 存储配置单元查询的输出:

nohup hive -i transaction_testing.hive > nohup.out 2>&1 &

我的理解是 2>&1 将标准错误重定向到标准输出。

我的问题是,我是否也可以重定向标准以便所有内容都在一个文件中?

A Google search shows me that in linux std in is 0.

我可以编辑上面的代码片段以在 nohup 文件中也包含输入和标准错误吗?

例如假设 transactions_testing.hive 包含以下内容:

select *
from some_table
where fruits = 'apples';

我想输出文件以在顶部包含此命令以及在下面的查询结果。

如果 2>&1 将 std 错误重定向到 std out,0>&1 是否会对 std in 做同样的事情?我如何将它们合而为一?

nohup hive -i transaction_testing.hive > nohup.out 0>1&2>&1 &

0>&1 意味着任何 写入 到标准输入的东西都将被发送到 FD 1。但通常不会写入标准输入,它仅用于读取。

您可以简单地将输入文件复制到输出文件,然后在您 运行 命令时附加到它。

cp transaction_testing.hive nohup.out
nohup hive -i transaction_testing.hive >> nohup.out 2>&1