你能推荐一个允许在网络中的远程机器上调度任务的python工具/模块吗?
请注意,该解决方案不仅必须能够在远程计算机上运行某些作业/命令,而且还必须能够验证作业等是否仍在运行(例如,考虑这样一种情况:一台机器在分配了任务后死亡?)
发布于 2011-04-15 09:44:14
RPyC是一个透明和对称的Python库,用于远程过程调用、集群和分布式计算。下面是一个来自Wikipedia的示例
import rpyc
conn = rpyc.classic.connect("hostname") # assuming a classic server is running on 'hostname'
print conn.modules.sys.path
conn.modules.sys.path.append("lucy")
print conn.modules.sys.path[-1]
# a version of 'ls' that runs remotely
def remote_ls(path):
ros = conn.modules.os
for filename in ros.listdir(path):
stats = ros.stat(ros.path.join(path, filename))
print "%d\t%d\t%s" % (stats.st_size, stats.st_uid, filename)
remote_ls("/usr/bin")
# and exceptions...
try:
f = conn.builtin.open("/non/existent/file/name")
except IOError:
pass要检查远程服务器在分配作业后是否已终止,可以使用Connection类的ping方法。完整的应用编程接口描述为here。
发布于 2011-04-15 11:50:55
Fabric (http://docs.fabfile.org/en/1.0.1/index.html)是用于各种系统管理和部署任务的非常好的工具包。它提供了一些预定义的任务,但也让您可以灵活地添加所需的内容。
我强烈推荐它。
发布于 2011-04-15 09:40:50
应该能够使用Python WMI,对于基于*NIX的系统,它是关于SSH和CRON的wrap。
https://stackoverflow.com/questions/5671527
复制相似问题