实现两个目录的同步
import subprocess
import sys
import time
import os
source='/home/dcr/testpython/test03'
target='/home/dcr/testpython/test02'
rsync="rsync"
arguments="-av"
cmd="%s %s %s %s"%(rsync,arguments,source,target)
def sync():
while True:
ret=subprocess.call(cmd,shell=True,stdout=open('sync.log','wa'),stderr=open('sync_err.log','wa'))
if ret!=0:
print "rsync faild!"
time.sleep(10)
else:
print "rsync successful"
#subprocess.call("mail -s 'jobs done' a@a.com",shell=True)
sys.exit(0)
sync()
阅读(1543) | 评论(1) | 转发(0) |