【记录】使用python并行执行shell
#!/usr/bin/python# -*- coding: utf-8 -*-
import sys
import subprocess
import os
'''
argv日期
argv本地rsync路径【暂时没用】
argv远程rsync ip
argv任务列表地址
'''
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!="taskId":
taskId=line;
userId=line;
emails=line;
taskName=line;
task_type=line;
userPath=line;
flag=line;
a1=line;
a2=line;
a3=line;
a4=line;
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,sys.argv,sys.argv,sys.argv);
r.run();
页:
[1]