> ## Content Index
> Fetch the complete content index at: https://blog.k3s.9zf.net/llms.txt
> Use this file to discover other available public pages before exploring further.

# ssh 关闭后仍保持当前运行的进程
- URL: https://blog.k3s.9zf.net/ssh--e5-85-b3-e9-97-ad-e5-90-8e-e4-bb-8d-e4-bf-9d-e6-8c-81-e5-bd-93-e5-89-8d-e8-bf-90-e8-a1-8c-e7-9a-84-e8-bf-9b-e7-a8-8b/
- Published: 2009-05-15T22:01:32.000Z
- Updated: 2009-05-15T22:01:32.000Z
- Author: liu
- Tags: 生活日记, #wordpress, #Import 2026-10-29 06:11

由于各种原因，需要通过ssh登录linux或者unix主机，很多时候我们需要通过ssh的终端启动一些服务或者运行一些程序，但是默认情况下，当我们关闭ssh终端连接，随之启动的程序也会关闭。原因是：SSH会话关闭时，ssh所关联的pty关闭，系统会给这个pty所关联的session中的所有进程发送SIGHUP信号，SIGHUP的默认信号处理程序是终止进程，除非进程自己处理了SIGHUP。

解决方法如下：

使用现成的命令nohup，可以让指定的程序在pty关闭之后继续运行。

运行方法：

#nohup program &

现在就可以正常关闭ssh了，你会发现你的服务依然存在运行

文章转载自：宇宏的博客 \[http://www.im286.net.cn\]