在 CentOS 中,nohup
命令用于在后臺運行程序,即使關閉終端或斷開連接,程序也會繼續運行
nohup your_command < input_file.txt 2>&1 &
這里,< input_file.txt
表示將 input_file.txt
文件作為輸入重定向到 your_command
。2>&1
表示將標準錯誤輸出(2)重定向到標準輸出(1),&
表示將命令放入后臺運行。
nohup your_command <(command_to_generate_input) &
這里,<(command_to_generate_input)
表示將 command_to_generate_input
命令的輸出作為輸入重定向到 your_command
。這種方法允許您在不創建臨時文件的情況下進行輸入重定向。
注意:在使用這些方法時,請確保您的程序能夠正確處理來自標準輸入的數據。