可能的重复:
如何在不终止其中运行的命令的情况下关闭终端?
我有一个运行 Debian Squeeze 的非常低端的“服务器”,我偶尔会通过 ssh 连接到它。系统往往很慢,例如运行apt-cache search
可能需要半分钟。有时我发现我迫不及待地等待一个过程完成(我在我的笔记本电脑上,需要去某个地方)。
如果我最初使用nohup
或 inside开始该过程screen
,这将没有问题。但是,尽管我已注销,但如何让已经在运行的进程继续运行?
Chr*_*own 11
假设您使用的是 bash、ksh、zsh 或其他类似的 shell,您可以将进程后台运行,然后运行disown
. 具体来说,在bash
您可能想要disown -h
.
从 bash 的帮助页面disown
:
disown: disown [-h] [-ar] [jobspec ...]
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.
Run Code Online (Sandbox Code Playgroud)
如果您使用 bash 或 zsh,请disown
在注销前使用内置程序。
来自man zshall
:
disown [ job ... ]
job ... &|
job ... &!
Remove the specified jobs from the job table; the shell will no
longer report their status, and will not complain if you try to
exit an interactive shell with them running or stopped. If no
job is specified, disown the current job.
Run Code Online (Sandbox Code Playgroud)