在 CentOS 系统中,nohup 命令用于在后台运行程序,即使关闭终端或断开连接,程序也会继续运行
使用 nohup 命令捕获标准错误的方法如下:
nohup your_command > output.log 2>&1 &
这里,your_command 是你要运行的命令。> 将标准输出重定向到 output.log 文件,2>&1 将标准错误重定向到标准输出(即 output.log 文件),最后的 & 将命令放入后台运行。
nohup your_command > output.log 2> error.log &
这里,your_command 是你要运行的命令。> 将标准输出重定向到 output.log 文件,2> 将标准错误重定向到 error.log 文件,最后的 & 将命令放入后台运行。
这样,你可以分别查看标准输出和标准错误的信息。在程序运行结束后,可以使用 cat 命令查看日志文件:
cat output.log
cat error.log