nohup 命令是 Linux 和 Unix 系统中用于在后台运行程序的命令,即使关闭终端或断开连接,程序也会继续运行。以下是一些常用的 nohup 参数及其作用:
nohup command &
command,并将输出重定向到 nohup.out 文件。-a file
file。-c
-d
-e file
file。-h
-i
-l
-m mode
append、ignore 或 close,控制标准输入、输出和错误的处理方式。-n
-p pidfile
-q
-r
nohup.out。-s
-t
基本后台运行
nohup myprogram &
重定向输出到特定文件
nohup myprogram > output.log 2>&1 &
使用登录 shell 并忽略挂起信号
nohup -l -i myprogram &
创建 PID 文件
nohup -p /var/run/myprogram.pid myprogram &
通过合理使用这些参数,可以更好地控制 nohup 命令的行为,确保后台进程的稳定运行。