问题描述
可能重复:结果
<一href=\"http://stackoverflow.com/questions/285015/linux-$p$pvent-a-background-process-from-being-stopped-after-closing-ssh-client\">Linux: prevent从关闭SSH客户端
我有一个程序,需要花费大量的时间来完成。
它以root运行通过SSH。结果
我希望它继续运行我退出后,这是可能的,我会怎样做到这一点?
I have a program that takes a lot of time to finish.It is running as root over ssh.
I want it to continue to run after I logout,is this possible and how would I achieve this?
推荐答案
假设你有在前台运行的程序, preSS CTRL-Z ,然后:
Assuming that you have a program running in the foreground, press ctrl-Z, then:
[1]+ Stopped myprogram
$ disown -h %1
$ bg 1
[1]+ myprogram &
$ logout
如果只有一个工作,那么你并不需要指定作业号。只需使用不认-h
和 BG
。
If there is only one job, then you don't need to specify the job number. Just use disown -h
and bg
.
您preSS CTRL-Z。该系统暂停运行的程序,显示工号和停止的消息,并返回到一个bash提示。
You press ctrl-Z. The system suspends the running program, displays a job number and a "Stopped" message and returns you to a bash prompt.
您键入不认-h%1
命令(在这里,我已经使用了 1
,但你倒是用这标志着作业时显示的停止
消息中的工号),所以它忽略了 SIGHUP
信号(它不会被注销时停止)。
You type the disown -h %1
command (here, I've used a 1
, but you'd use the job number that was displayed in the Stopped
message) which marks the job so it ignores the SIGHUP
signal (it will not be stopped by logging out).
接下来,使用相同的作业号键入 BG
命令;这个恢复计划的在后台运行,并显示一条消息,确认。
Next, type the bg
command using the same job number; this resumes the running of the program in the background and a message is displayed confirming that.
您现在可以注销,它会继续运行。
You can now log out and it will continue running..
这篇关于如何让程序继续运行后,从SSH注销?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!