中运行命令并在关闭会话时继续运行该命令

中运行命令并在关闭会话时继续运行该命令

本文介绍了在 shell 中运行命令并在关闭会话时继续运行该命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Putty 连接到远程服务器.我想知道的是,在我关闭与 Putty 的会话后,是否有任何方法可以编写我的命令并允许它们继续运行.这样做的原因是我不想让电脑一直开着.有没有办法做到这一点?

I am using Putty to connect to a remote server. What I want to know is if there is any way to write my commands and allow them to keep running after I close the session with Putty. The reason for this is that I do not want to keep the computer ON all the time. Is there any way to do this?.

更新解决方案

对于我提出的问题,最好的解决方案是使用提供的命令之一,例如 nohup,因为您不必安装任何其他软件.但是,如果您遇到同样的问题,请安装并使用它.太棒了.

For my question as it is presented the best solution is use one of the commands provided such as nohup, because you do not have to install any additional software. But if you are in the same problem use screen, install it and use it. It is amazing.

我选择了 Norman Ramsey 的答案作为最喜欢的答案,因为使用命令和 screen 提出了几种解决方案.但请检查其他答案,特别是 PEZ 的答案,然后您就会了解屏幕能够做什么.

I have selected the answer of Norman Ramsey as favourite because propose several solutions using commands and screen. But please check the other answers specially the one of PEZ, then you get an insight of what screen is able todo.

推荐答案

nohupdisownscreen都不错,但是screen 是最好的,因为与其他两个不同,screen 允许您断开与远程服务器的连接,保持一切运行,然后稍后重新连接以查看发生了什么.使用 nohupdisown 您无法恢复交互.

nohup, disown, and screen are all good but screen is the best because unlike the other two, screen allows you to disconnect from the remote server, keep everything running, and then reconnect later to see what is happening. With nohup and disown you can't resume interacting.

这篇关于在 shell 中运行命令并在关闭会话时继续运行该命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 16:05