我想将这些文件rsync同步到我的本地linux机器上,但我只想要在过去30天内创build或修改的文件。
我正在使用这个命令从Linux安装一个Windows共享:
mount -t cifs //Share/public /mnt/ntserver -o username=myuser,password='password',domain=sub.domain.com
它正确安装,我可以坐山:
$ mount //Share/public/ on /mnt/ntserver type cifs (rw,mand)
从我的研究看来,似乎rsync不能单独做这件事,但在'find'的帮助下,这是可能的。
下面这个命令只是find30天前刚刚创build或修改的文件(从-ctime 30开始),它没有返回任何要rsynced的文件。
cd /mnt/ntserver/documentation/ && find . -type f -ctime 30 | rsync -av --max-size=5m --include '*/' --include '*.xls*' --include '*.doc*' --include '*.pl' --include '*.sh' --include '*.sql' --include '*.txt' --include '*.vsd' --exclude '*' --files-from=- /mnt/ntserver/documentation /home/dan/cifs/ building file list ... done sent 10 bytes received 12 bytes 2.93 bytes/sec total size is 0 speedup is 0.00
但是,如果我将-ctime更改为29,则会find文件:
cd /mnt/ntserver/documentation/ && find . -type f -ctime 29 | rsync -av --max-size=5m --include '*/' --include '*.xls*' --include '*.doc*' --include '*.pl' --include '*.sh' --include '*.sql' --include '*.txt' --include '*.vsd' --exclude '*' --files-from=- /mnt/ntserver/documentation /home/dan/cifs/ building file list ... done doc1.xlsx doc2.xlsx doc3.xlsx sent 6657515 bytes received 91 bytes 783247.76 bytes/sec total size is 14039237 speedup is 2.11
我究竟做错了什么? 为什么不find过去30天内创build/修改的所有文件?
使用-ctime -30 。 请注意-30 ,而不仅仅是30 。