【记录】使用python并行执行shell



#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import subprocess
import os


'''
argv[1] 日期
argv[2] 本地rsync路径【暂时没用】
argv[3] 远程rsync ip
argv[4] 任务列表地址

'''
class RsyncTask:
def __init__ (self,date,localpath,ip,taskpath) :
self.date = date;
self.localpath = localpath;
self.ip = ip;
self.taskpath = taskpath;

def run(self):
# file_log=open("/data1/result/baby/log","a+");
file = open(self.taskpath,'r');
while 1:
file_lines = file.readlines(100000);
if not file_lines:
break
for lines in file_lines:
line=lines.split("\t");
if line[0]!="taskId":
taskId=line[0];
userId=line[1];
emails=line[2];
taskName=line[3];
task_type=line[4];
userPath=line[5];
flag=line[6];
a1=line[7];
a2=line[8];
a3=line[9];
a4=line[10];
cmd="sh /usr/home/baby/shell/usertool/deal_tblog_user_rsync.sh " + self.date +" " + taskId + " " + userId + " " + emails + " " + taskName + " " + task_type + " " + userPath + " " + self.ip + " " + flag + " " + a1 + " " + a2 + " " + a3 + " " + a4;
p=subprocess.Popen(cmd,shell=True);

file.close();
if __name__ == '__main__':
r=RsyncTask(sys.argv[1],sys.argv[2],sys.argv[3],sys.argv[4]);
r.run();

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值