python 对shell 命令的 执行 逻辑 在一台机器上执行另一台机器的命令; 跨节点 执行命令

 

import os

l = ['ssh a;scp /data/visitlog/*11* root@d:/data/mapReduceVisitorLog/'] # b c
for i in l:
os.system(i)



在执行py脚本前,配置好了免密登录;
python this_.py
成功登录到a服务器,但是剩下的不能执行;


实现思路:
事件触发机制;
各个节点 http 监听;收到后执行命令;




import os

sh_, nodes = 'ssh A "scp /data/visitlog/* root@d:/data/mapReduceVisitorLog/A/"', ['a', 'b', 'c']

for i in nodes:
s = sh_.replace('A', i)
os.system(s)



python 执行 python 文件
import os

sh_, nodes = 'ssh A "scp /data/visitlog/* root@d:/data/mapReduceVisitorLog/A/"', ['a', 'b', 'c']

for i in nodes:
s = sh_.replace('A', i)
os.system(s)

os.system('python mapReduceBatchDeleteLoopDate20180101-20200101.py')
os.system('python mapReduceBatchDeleteLoopDateDealLog20180101-20200101.py')






posted @ 2018-11-29 15:27  papering  阅读(1043)  评论(0编辑  收藏  举报