#Bash 的 disown 命令
disown [OPTION]... [ID]...
功能
从当前 shell 中移除作业。
被移除的作业仍然运行。
类型
Bash 内置命令。
参数
OPTION选项:-a- 移除所有作业-h- 标记作业,使得在 shell 收到SIGHUP信号时,不会向该作业发送SIGHUP信号-r- 仅移除正在运行的作业
ID- 进程 ID,可以使用以下特殊参数%1- 第一个作业的进程 ID,以此类推%+- 当前作业(最后一个暂停的作业)的进程 ID%-- 上一个作业(最后一个后台作业)的进程 ID
#示例
$ java -jar minecraft_server.jar nogui # & 表示后台运行,然后按 Ctrl + Z 暂停
^Z
[1]+ Stopped nohup java -jar minecraft_server.jar nogui
$ bg # 转为后台运行
[1]+ nohup java -jar minecraft_server.jar nogui &
$ disown -h %1 # 将该作业移除,并使其不会收到 SIGHUP 信号
#相关命令
#推荐阅读
#手册
disown: disown [-h] [-ar] [jobspec ... | pid ...]
Remove jobs from current shell.
Removes each JOBSPEC argument from the table of active jobs. Without
any JOBSPECs, the shell uses its notion of the current job.
Options:
-a remove all jobs if JOBSPEC is not supplied
-h mark each JOBSPEC so that SIGHUP is not sent to the job if the
shell receives a SIGHUP
-r remove only running jobs
Exit Status:
Returns success unless an invalid option or JOBSPEC is given.