检查远程计算机上是否正在运行python脚本 [英] Check if a python script is running on remote machine

查看:155
本文介绍了检查远程计算机上是否正在运行python脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在说机器A上运行python脚本。是否可以通过命令行从另一台机器B上了解该python脚本是否正在运行?我尝试从任务管理器中获取进程列表。但是,尽管它正在运行,但它没有显示有关此脚本的任何信息(它仅显示脚本通过其执行的cmd)。

I am running a python script on say machine A. Is there any way to know if the python script is running or not from another machine B from command line? I tried getting the process list from the task manager. But it does not show any information regarding this script though it is running( it only showed cmd through which the script is executing ).

推荐答案

这将是一个三步过程。仅因为您是Windows,才需要执行步骤1。如果您使用的是Mac或Linux,则它们已经为您完成了第1步。否则,这将完全具有跨平台功能。

This will be a three step process. Step 1 is only required because you are Windows. If you're Mac or Linux, they already come with Step 1 completed for you. Otherwise, this is completely cross-platform capable.

1)您需要从计算机A远程连接到计算机B。一种非常流行的方法是SSH,SSH可以将其安装在机器A和机器B上。推荐的方法是使用FreeSSHd,此处已对此进行了很好的记录:> https://serverfault.com/questions/8411/what-is-a-good-ssh-server-to-use-on-windows

1) You need to remotely connect from Machine A to Machine B. One extremely popular way of doing this is SSH, which can be installed on Machine A and Machine B. The recommended way to do this is with FreeSSHd, which has been very well documented here: https://serverfault.com/questions/8411/what-is-a-good-ssh-server-to-use-on-windows

2)安装适用于Python的paramiko SSH库。这将使您可以连接到另一台计算机,并执行任意命令行命令。在Windows上,您只需要安装paramiko和pycrypto / openssl的二进制文件。此处也对此进行了详细记录:在Windows上安装paramiko

2) Install the paramiko SSH library for Python. This will allow you to connect to another machine, and execute any arbitrary command line command. On windows, you just need to install the binaries for paramiko and pycrypto/openssl. This also is well documented on SO here: installing paramiko on Windows

3)决定要如何收集流程列表。有几种方法在此处有详细记录: https://stackoverflow.com/questions/53489/how-do-you-list-all-processes-on-the-command-line-in-windows

3) Decide how you want to harvest the process list. There are several ways which are well documented here: https://stackoverflow.com/questions/53489/how-do-you-list-all-processes-on-the-command-line-in-windows

这篇关于检查远程计算机上是否正在运行python脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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