nohup(no hang-up)命令用于在后台运行程序,使其不受终端关闭的影响。以下是nohup命令的一些常用参数:
nohup command &
command,并将输出重定向到nohup.out文件。-a
nohup command -a output.log &-c
nohup command -c &-d
nohup command -d error.log &-e
nohup command -e output.log &-f
fork()系统调用,即使当前shell不支持后台运行。nohup command -f &-h
-i
nohup command -i &-l
nohup command -l &-m
nohup command -m exit_status.log &-n
/dev/null,即丢弃标准输出。nohup command -n &-p
nohup command -p error.log &-q
-r
nohup command -r &-s
nohup command -s output.log &-t
nohup command -t error.log &# 在后台运行命令,并将标准输出和标准错误都重定向到output.log
nohup command -a output.log &
# 在后台运行命令,并忽略挂起信号
nohup command -i &
# 在后台运行命令,并将标准输出重定向到/dev/null
nohup command -n &
nohup命令默认会将输出重定向到nohup.out文件,除非指定了其他文件。&符号将命令放入后台运行。nohup,否则进程会在终端关闭时被终止。通过这些参数,你可以灵活地控制nohup命令的行为,以满足不同的需求。