nohup 命令在 Debian 和其他 Linux 发行版中的语法格式如下:
nohup command-to-run &
其中:
nohup 是 “no hang up” 的缩写,表示该命令在用户退出登录后仍然继续运行。command-to-run 是你想要执行的命令或脚本。& 符号将命令放入后台运行。通常,nohup 命令还会将输出重定向到一个名为 nohup.out 的文件中,除非你指定了其他输出文件。例如:
nohup command-to-run > output.log 2>&1 &
在这个例子中:
> 将标准输出重定向到 output.log 文件。2>&1 将标准错误输出重定向到标准输出,这样错误信息也会被写入 output.log 文件。& 将命令放入后台运行。使用 nohup 命令时,建议将输出重定向到一个文件,以避免输出到终端并可能导致的混乱。