在 CentOS 中,nohup 命令用于在后台运行程序,即使关闭终端或断开连接,程序也会继续运行
nohup your_command > output.log 2>&1 &
这里,your_command 是你要运行的命令。> 将标准输出重定向到 output.log 文件。2>&1 表示将标准错误(stderr)重定向到标准输出(stdout),这样错误信息也会被写入 output.log 文件。最后的 & 符号表示将命令放入后台运行。
nohup your_command > output.log &
这种情况下,只有标准输出会被重定向到 output.log 文件,而标准错误仍然会显示在终端上。
nohup your_command > output.log 2> error.log &
这里,> 将标准输出重定向到 output.log 文件,而 2> 将标准错误重定向到 error.log 文件。
注意:在使用这些命令时,请确保将 your_command 替换为你实际要执行的命令。