在 CentOS 中,nohup 命令用于在后台运行程序,即使关闭终端或断开连接,程序也会继续运行。默认情况下,nohup 会将标准输出和标准错误输出重定向到名为 nohup.out 的文件中。
如果你想单独处理错误输出,可以使用以下方法:
nohup your_command 2> error_output.log &
这里,2> 表示将标准错误输出(文件描述符为 2)重定向到 error_output.log 文件中。& 表示将命令放入后台运行。
nohup your_command > output.log 2> error_output.log &
这里,> 表示将标准输出(文件描述符为 1)重定向到 output.log 文件中。
tail 命令实时查看日志文件:tail -f error_output.log
这样,你可以实时查看错误输出,而不必每次都打开日志文件。