linux-正在运行的进程背景 [英] linux - running process background

查看:253
本文介绍了linux-正在运行的进程背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在远程linux服务器上运行一个进程,并在关闭腻子终端后使该进程保持活动状态,

I want to run a process in a remote linux server and keep that process alive after close the putty terminal,

什么是正确的命令?

推荐答案

您有两个选择:

  1. 使用 GNU屏幕,这将允许您运行命令并将其与您的命令分离.终端,然后将其重新连接到其他会话.我将其用于长时间运行的进程,希望可以随时监视其输出.屏幕是一个真正强大的工具,我强烈建议您花一些时间来学习它.
  2. nohup some-command &身份运行命令,它将在后台运行该命令,将其与控制台分离,然后将其输出重定向到nohup.out.它将吞下发送到该进程的SIGHUP. (当您关闭终端或注销时,SIGHUP会发送到由登录外壳程序启动的所有进程,内核将采取的默认操作是终止该进程.这就是为什么添加&来放置该进程的原因在后台还不足以使其在注销后仍然幸存.)
  1. Use GNU screen, which will allow you to run the command and detach it from your terminal, and later re-attach it to a different session. I use it for long-running processes whose output I want to be able to monitor at any time. Screen is a truly powerful tool and I would highly recommend spending some time to learn it.
  2. Run the command as nohup some-command &, which will run the command in the background, detach it from the console, and redirect its output into nohup.out. It will swallow SIGHUPs that are sent to the process. (When you close the terminal or log out, SIGHUP is sent to all processes that were started by the login shell, and the default action the kernel will take is to kill the process off. This is why appending & to put the process in the background is not enough for it to survive a logout.)

这篇关于linux-正在运行的进程背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆