nohup
命令的全称为“no hang up”,该命令可以将程序以忽略挂起信号的方式运行起来,被运行的程序的输出信息将不会显示到终端。
无论是否将 nohup
命令的输出重定向到终端,输出都将附加到当前目录的 nohup.out
文件中。如果当前目录的 nohup.out 文件不可写,输出重定向到$HOME/nohup.out
文件中。如果没有文件能创建或打开以用于追加,那么 command 参数指定的命令不可调用。如果标准错误是一个终端,那么把指定的命令写给标准错误的所有输出作为标准输出重定向到相同的文件描述符。
语法格式:nohup [参数]
常用参数:
参数 | 说明 |
---|---|
–help | 在线帮助 |
–version | 显示版本信息 |
2. 参考实例
- 使用nohup 命令在后台运行程序
> nohup java -jar dreamhai.jar &
- 至此输出文件,输出被重定向到 dreamhai.com文件中
> nohup command > dreamhai.com 2>&1
3. 系统文档(mkdir man)
NOHUP(1) User Commands NOHUP(1)
NAME
nohup - run a command immune to hangups, with output to a non-tty
SYNOPSIS
nohup COMMAND [ARG]...
nohup OPTION
DESCRIPTION
Run COMMAND, ignoring hangup signals.
--help display this help and exit
--version
output version information and exit
If standard input is a terminal, redirect it from an unreadable file. If standard output is a terminal, append output to 'nohup.out' if possible, '$HOME/nohup.out' otherwise. If standard
error is a terminal, redirect it to standard output. To save output to FILE, use 'nohup COMMAND > FILE'.
NOTE: your shell may have its own version of nohup, which usually supersedes the version described here. Please refer to your shell's documentation for details about the options it sup‐
ports.
AUTHOR
Written by Jim Meyering.
REPORTING BUGS
GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
Report nohup translation bugs to <http://translationproject.org/team/>
COPYRIGHT
Copyright © 2016 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
SEE ALSO
Full documentation at: <http://www.gnu.org/software/coreutils/nohup>
or available locally via: info '(coreutils) nohup invocation'
GNU coreutils 8.25 February 2016 NOHUP(1)