#!/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();
【记录】使用python并行执行shell
最新推荐文章于 2024-08-12 10:21:02 发布