在 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。这种方法允许您在不创建临时文件的情况下进行输入重定向。
注意:在使用这些方法时,请确保您的程序能够正确处理来自标准输入的数据。