简体   繁体   English

如何独立于当前计算机使用SSH远程运行程序

[英]How to remotely run a program with SSH independent of my current computer

So I want to run a program from my Desktop, but I would like to have my Desktop "forget it", so that if my Desktop crashes or shuts down it won't affect the SSH program. 所以我想从我的桌面上运行一个程序,但是我想让我的桌面“忘记它”,这样,如果我的桌面崩溃或关闭,它将不会影响SSH程序。

In other words: I want the task to be executed on the remote computer independent of the computer, with which I'm sending the task. 换句话说:我希望任务可以在与我发送任务的计算机无关的远程计算机上执行。

Why would I wanna do this? 我为什么要这样做? Because I'm executing a huge task on a huge computer (64 cores computer), which should take days to evaluate, but I don't want my current computer to have to wait for it. 因为我正在一台大型计算机(64核计算机)上执行一项巨大的任务,这需要花费数天的时间进行评估,但是我不希望当前的计算机必须等待它。 The last time my Desktop froze, and I lost all the progress I had. 上次我的桌面冻结时,我失去了所有的进度。

I can imagine that this question has been answered a million times already, but I don't know what terminology I have to search for, and I don't know what this process is called. 我可以想象这个问题已经被回答了一百万遍了,但是我不知道我要搜索什么术语,也不知道这个过程叫什么。

Thanks. 谢谢。

Some methods 一些方法

  • Use nohup 使用nohup
  • Use Screen 使用画面

Using Screen 使用屏幕

Ubuntu : sudo apt-get install screen Ubuntu: sudo apt-get install screen

 screen 

then after you lost ssh session. 然后在您失去了ssh会话之后。

login to ssh again and then 再次登录ssh然后

screen -r 

This will resume ssh session screen. 这将恢复ssh会话屏幕。

For more info man screen 有关更多信息的man screen

You could use (on the remote big iron) the batch(1) command since you want batch processing : 您可以使用(在远程大型服务器上) batch(1)命令,因为您要进行批处理

  local% ssh remotebigmachine
  remotebigmachine% batch << EOB
     ./myprog param1 param2 param3 > output.txt
  EOB
  remotebigmachine% exit

In the above both local% and remotebigmachine% are shell prompts (in practice they are something different). 在上面, local%remotebigmachine%都是shell提示(实际上它们是不同的)。

BTW, for batch computation running many days, it is worthwhile to program some application checkpointing (because even supercomputers may have power outages or hardware issues). 顺便说一句,对于运行数天的批处理计算,值得对一些应用程序检查点进行编程(因为即使超级计算机也可能会出现断电或硬件问题)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM