在 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
替換為你實際要執行的命令。