SSH连接-运行程序->如何在 ssh 连接关闭时保持程序运行
简而言之: 当远程服务器连接关闭(shell 窗口关闭)时,保持 perl/python/R/etc 脚本/程序在服务器上运行(通过 ssh 连接)的最优雅的解决方案是什么?
详细信息: 我编写了一些将在我们的服务器上运行几天的脚本。然而,在通过 linux-shell 通过 SSH 连接到服务器后,启动程序并关闭窗口也会杀死该程序 - 好吧,这不是什么新鲜事。但是,服务器必须如何配置才能在 ssh 连接关闭后保持程序运行? “屏幕”可以是一种解决方案,嗯,但对我来说,打字太多,有时我忘记启动屏幕会话并启动程序,
谢谢您的建议!
干杯, 雪人
In short:
What is the most elegant solution to keep a perl/python/R/etc script/program running on a server (connected via ssh) when the remote server connection is closed (shell-window closed)?
In detail:
I have written some scripts that will run several days on our server. However, after connecting to the server via SSH over a linux-shell, starting the program and closing the window will also kill the program - OK, thats not new. But, how must the Server be configured to keep the program running after the ssh-connection is closed?
"screen" can be one solution, hmm but for me that to much typing and sometime I forgot to start a screen session and start the program
Thanks for your advice!
Cheers,
Yeti
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
NOHUP - http://en.wikipedia.org/wiki/Nohup
NOHUP - http://en.wikipedia.org/wiki/Nohup
如果您查看 ssh 的手册页,您可以在“-n”选项下方找到示例。
if you see the man page of ssh you can find an example below the "-n" option.
希望其他人可能会发现这个问题并发现此信息有用,有一个名为“screen”的应用程序”也可以让您实现这一目标。
大多数发行版应该将它们放在其存储库中的
screen
包名称下。如果我想制作一个屏幕,我只需运行 screen -dmS screenName 命令,它将在不同的“屏幕”中运行该命令,可以通过 screen -r screenName 访问该命令/代码>。您可以随时使用 CTRL+A+D 分离屏幕。我希望有人可以从这些信息中受益,因为当您想要运行一个进程但也能够查看其输出(假设它有任何输出)(我的许多应用程序都这样做)时,它很有用。
In the hope that someone else might find this question and find this information useful, there is an application called "screen" out there that can also let you achieve this.
Most distributions should have them in their repositories under the
screen
package name. If I wanted to make a screen, I would simply runscreen -dmS screenName command
and it would run the command in a different "screen", which can be accessed withscreen -r screenName
. You can detach from a screen at any time using CTRL+A+D.I hope someone can benefit from this information, as it is useful when you'd like to run a process but also be able to review its output assuming it has any (which many of my applications do).