在Debian系统中,nohup命令用于在后台运行程序,即使关闭终端或断开连接,程序也会继续运行
以下是如何使用nohup将输出重定向到文件的示例:
nohup your_command > output.log 2>&1 &
在这个示例中:
your_command 是您要运行的命令。> 将标准输出(stdout)重定向到 output.log 文件。2>&1 将标准错误(stderr)重定向到标准输出(stdout),这样错误信息也会被写入 output.log 文件。& 将命令放入后台运行。例如,如果您想在后台运行一个名为 my_script.sh 的脚本,并将输出重定向到 output.log 文件,您可以这样做:
nohup ./my_script.sh > output.log 2>&1 &
运行此命令后,您可以使用 tail -f output.log 命令实时查看输出日志。