标签:
[root@shaw ~]#vim scripts/ftp_sync.py #!/bin/env python import os,sys,shutil SDIR = ‘/ftp/xiantu/tmp/‘ DDIR = ‘/ftp/shaw/soft/‘ os.system(‘cd‘) os.system(‘/bin/ls %s > sdirlist.txt‘ %SDIR) with file(‘sdirlist.txt‘,‘r+‘) as f: for i in f.readlines(): if os.path.isfile(‘%s+%s‘ % (DDIR,i.strip())): pass else: shutil.copy(‘%s%s‘% (SDIR,i.strip()),‘%s‘% DDIR) os.remove(‘sdirlist.txt‘)
利用crontab实现自动同步
[root@shaw ~]# crontab -l */5 * * * * /root/scripts/ftp_sync.py
标签:
原文地址:http://my.oschina.net/u/2428313/blog/492475