简体   繁体   English

使用Python脚本重启远程服务器

[英]Restart remote servers with a Python script

I'm trying to write a Python script that will restart a series of servers on the same network in a specified sequence. 我正在尝试编写一个Python脚本,该脚本将按指定顺序重新启动同一网络上的一系列服务器。 I have used os.system('shutdown /r') to restart my own machine, but I cannot find the documentation to shutdown remote servers with usernames and passwords. 我已经使用os.system('shutdown / r')重新启动自己的计算机,但是找不到用于关闭具有用户名和密码的远程服务器的文档。 I eventually want to run the Python script from a Raspberry Pi on the push of a button. 我最终想按一个按钮从Raspberry Pi运行Python脚本。 Can someone point me in the right direction? 有人可以指出我正确的方向吗?

This article explains in detail how to configure remote shutdown for Windows: http://www.howtogeek.com/109655/how-to-remotely-shut-down-or-restart-windows-pcs/ 本文详细说明了如何为Windows配置远程关机: http : //www.howtogeek.com/109655/how-to-remotely-shut-down-or-restart-windows-pcs/

Note that you will need Samba to get a net command which you can run from Linux. 请注意,您将需要Samba来获取可以从Linux运行的net命令。

If that is no available, then the workaround is to write a small server in Python which you install on a Windows box which accepts the "restart everything" command from the Pi (use a plain socket server but implement some kind of password protection). 如果不可用,则解决方法是用Python编写一个小型服务器,将其安装在Windows框中,该服务器接受Pi的“重新启动所有内容”命令(使用普通套接字服务器,但实施某种密码保护)。

If you can access those servers through SSH, try Fabric 如果可以通过SSH访问这些服务器,请尝试使用Fabric

Very useful tool! 非常有用的工具!

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

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