SSH连接-运行程序->如何在 ssh 连接关闭时保持程序运行

发布于 2024-12-03 17:41:57 字数 340 浏览 0 评论 0原文

简而言之: 当远程服务器连接关闭(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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

海之角 2024-12-10 17:41:57

NOHUP - http://en.wikipedia.org/wiki/Nohup

ssh your_server
nohup nice perl your_script &
exit

NOHUP - http://en.wikipedia.org/wiki/Nohup

ssh your_server
nohup nice perl your_script &
exit
メ斷腸人バ 2024-12-10 17:41:57

如果您查看 ssh 的手册页,您可以在“-n”选项下方找到示例。

ssh -n <user>@<server> <cmd> &

if you see the man page of ssh you can find an example below the "-n" option.

ssh -n <user>@<server> <cmd> &
〃温暖了心ぐ 2024-12-10 17:41:57

希望其他人可能会发现这个问题并发现此信息有用,有一个名为“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 run screen -dmS screenName command and it would run the command in a different "screen", which can be accessed with screen -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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文