通过SSH执行远程python脚本 [英] Execute remote python script via SSH

查看:58
本文介绍了通过SSH执行远程python脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 SSH 在多台(15 岁以上)远程机器上执行 Python 脚本.调用脚本/命令后,我需要断开 ssh 会话并保持进程在后台运行,只要它们需要.

I want to execute a Python script on several (15+) remote machine using SSH. After invoking the script/command I need to disconnect ssh session and keep the processes running in background for as long as they are required to.

我过去使用过 Paramiko 和 PySSH,所以再次使用它们没有问题.我唯一需要知道的是如何在 python 中断开 ssh 会话(因为通常本地脚本会在继续之前等待每个远程机器完成处理).

I have used Paramiko and PySSH in past so have no problems using them again. Only thing I need to know is how to disconnect a ssh session in python (since normally local script would wait for each remote machine to complete processing before moving on).

推荐答案

这可能有用,或者类似的:

This might work, or something similar:

ssh user@remote.host nohup python scriptname.py &

基本上,请查看 nohup 命令.

Basically, have a look at the nohup command.

这篇关于通过SSH执行远程python脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆