在nohup
命令中重定向标准错误(stderr)到文件,可以使用以下方法:
- 使用
2>
操作符将标准错误重定向到文件。例如,如果你想将错误信息重定向到名为error.log
的文件,可以使用以下命令:
nohup your_command 2> error.log &
这将在后台运行your_command
,并将所有错误信息写入error.log
文件。
- 如果你还想将标准输出(stdout)重定向到同一个文件,可以使用以下命令:
nohup your_command > output_and_error.log 2>&1 &
这会将标准输出和标准错误都重定向到output_and_error.log
文件,并在后台运行your_command
。
- 如果你想将标准输出和标准错误分别重定向到不同的文件,可以使用以下命令:
nohup your_command > output.log 2> error.log &
这会将标准输出重定向到output.log
文件,将标准错误重定向到error.log
文件,并在后台运行your_command
。