是否有可能从terminal上分离进程? (或者,“我应该使用屏幕!”)

可能重复:
我可以禁止/屏蔽已经启动的程序吗?

在Unix(特别是Linux)上,我在一个普通的ssh-> bash会话中开始了一个工作。 我想尽快离开工作,但现在我意识到这项工作将需要几个小时。

如果我刚刚在屏幕上开始这项工作,我可以离开,回家。 但是我没有。

有没有办法断开工作与其SSH会话,所以我可以closures我的电脑,(删除TCP连接,并杀死SSH会话),但有程序继续运行?

我不关心它的输出 – 事实上,我将stdoutredirect到一个文件。 我只是想让它运行完成。

    您可以按ctrl-z中断进程,然后运行bg使其在后台运行。

    您可以显示一个编号列表,以这种方式与jobs背景的所有进程。

    然后,您可以运行disown %1 (用jobs输出的进程编号replace1 ),以将进程从terminal分离。

    不pipe名字如何,这个过程在你离开之后仍然由你来拥有,它只会从你开始的terminal上分离出来。

    这个答案有更多的信息

    我相信你正在寻找的命令是“disown”

    从你的bash shell中:

     control+z 

    然后,继续在后台运行该作业:

     bg 

    稍后,您可以键入jobs以查看您的进程是否仍在运行。

    当在屏幕内使用reptyr时 ,您可以将进程(或其输出)移动到屏幕中。

    使用crtl-Z然后在运行命令时使用bg或使用&在100%时不可靠。 它将在大多数情况下工作,但在某些情况下可能无法正常工作(I / O使用,…)。
    屏幕是可靠的解决scheme。

    当我连接到我经常使用的主机时,我已经设置了屏幕自动运行,以避免这个问题。

    http://tlug.dnho.net/?q=node/239是这样做的一种方式,虽然有其他的变化。

    当我在中途断线的时候,已经救了我一两次,否则在我开始长时间的事情之前忘记了开始屏幕。

    如果你正在使用bash,你可以使用bg来控制Z和背景。

    工作控制 (从男子bash)

      If the operating system on which bash is running supports job control, bash contains facilities to use it. Typing the suspend character (typically ^Z, Control-Z) while a process is running causes that process to be stopped and returns control to bash. Typing the delayed suspend character (typically ^Y, Control-Y) causes the process to be stopped when it attempts to read input from the terminal, and control to be returned to bash. 

    帮助bg

     bg: bg [job_spec ...] Place each JOB_SPEC in the background, as if it had been started with `&'. If JOB_SPEC is not present, the shell's notion of the current job is used. 

    帮助工作

     jobs: jobs [-lnprs] [jobspec ...] or jobs -x command [args] Lists the active jobs. The -l option lists process id's in addition to the normal information; the -p option lists process id's only. 

    如果你事先知道你想让它在后台运行,unix命令是一个不错的select。 它在预定的时间在后台启动命令,就像一个不重复的cron作业。 根据您的发行版,您可能需要安装它并启动atd守护进程。

    使用
     nohup命令&
    
    是美丽的:
     root @ index:〜#nohup / usr / bin / curl localhost / begemot.php&
     [8] 894
     root @ index:〜#nohup:忽略input并将输出追加到`nohup.out'
    
    并离开这个terminal,任务继续下去...