rsync同步管理工具,rsync同步工具,[Python]代码#/


[Python]代码

#/usr/bin/env python#--encoding=UTF-8--#auth@:xfk#data@:2012-04-12#blog:blog.sina.con.cn/kaiyongdengimport sysimport timeform sunprocess import callsource = "/tmp/sync_dir_A/"target = "/tmp/sync_dir_B/"rsync = "rsync"arguments = "-av"cmd = "%s %s %s %s"%(rsync,arguments,source,target)def sync():    while Ture:        ret = call(cmd,shell = Ture)        if ret !=0:            print "resubmitting rsync !"            time.sleep(20)        else:            print "rsync was successful !"            subprocess.call("mail -s 'jobs done !' username@example.com",shell = Ture)            sys.exit(0)if __name__ == "__main__":    sync()

评论关闭