nohup
命令用于在 Linux 中运行一个程序,使其在用户退出登录后继续运行
nohup command > output.log 2>&1 &
这里,command
是你要运行的命令。>
将标准输出重定向到 output.log
文件。2>&1
表示将标准错误(文件描述符 2)重定向到标准输出(文件描述符 1),&
表示将命令放入后台运行。
nohup command > output.log 2> error.log &
这里,output.log
文件用于存储标准输出,而 error.log
文件用于存储标准错误。
nohup command &> output.log &
这里,&>
表示将标准输出和标准错误都重定向到 output.log
文件。
注意:在使用 nohup
命令时,建议将输出重定向到一个日志文件,以便在需要时查看程序的输出和错误信息。同时,使用 &
将命令放入后台运行,以免阻塞终端。