即使连接丢失,也可以从我的计算机在远程计算机上运行脚本
我有一台远程计算机,我需要运行一些脚本,例如 ./main.sh
我正在使用 ssh 登录远程计算机并运行脚本,但是当网络连接丢失时,脚本不会运行跑吧。
即使连接丢失,如何从我的计算机在远程计算机上运行脚本?在此用例中是否有 ssh 的替代方案?
I have a remote machine where i need to run some script say ./main.sh
I am using ssh to login to the remote machine and run the script but when the network connection is lost the script doesn't run.
How can i run a script on my remote machine from my machine even when the connection is lost? Are there any alternatives to ssh in this use case?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果远程系统兼容 Unix,标准答案是使用 nohup。
If the remote system is Unix-compatible, the standard answer is to use
nohup
.如果您有权访问该计算机上的
cron
,请使用它(请参阅man cron
)进行常规运行。如果是单例场景,并且您希望它有时在登录后运行(即使连接丢失):登录后,启动
screen
会话并使用at
。If you have access to
cron
on that machine, use that (seeman cron
) for regular runs.If it's a single case scenario, and you want it to run sometimes after logging in (even if the connection is lost): after logging in, start a
screen
session and useat
.