Chinaunix首页 | 论坛 | 博客
  • 博客访问: 268954
  • 博文数量: 103
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 705
  • 用 户 组: 普通用户
  • 注册时间: 2013-05-02 16:15
文章分类

全部博文(103)

文章存档

2014年(8)

2013年(95)

我的朋友

分类: Python/Ruby

2013-05-02 18:06:34

实现两个目录的同步

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()
阅读(1506) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

校长的马夹2013-05-03 09:31:21

..  期待分享更多的原创博文