发布时间:2019-08-15 10:00:44编辑:auto阅读(2059)
python code rsync
- #!/usr/bin/env pyt hon
- #wraps up rsync to synchronize two directories
- from subprocess import call
- import sys
- import time
- """this motivated rsync tries to synchronize forever"""
- source = "/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 True:
- ret = call(cmd,shell=True)
- if ret !=0:
- print "resubmitting rsync"
- time.sleep(5)
- else:
- print "rsync was successful"
- cmd_mail="echo 'jobs done'|mail -s 'jobs done' itnihao@qq.com"
- call(cmd_mail,shell=True)
- sys.exit(0)
- sync()
上一篇: python重载方法
下一篇: python下载图片
50996
50379
40994
37861
32327
29219
28102
22932
22900
21227
1091°
1782°
1453°
1392°
1666°
1474°
2132°
3693°
3627°
2549°