I want to rsync the files to my local linux box, but I only want files that have been created or modified within the past 30 days.

I'm mounting a windows share from linux using this command:

mount -t cifs //Share/public /mnt/ntserver -o username=myuser,password='password',domain=sub.domain.com

It mounts correctly and I can ls the mount:

$ mount
//Share/public/ on /mnt/ntserver type cifs (rw,mand)

From my research, it seems rsync can't do this alone, but with the help of 'find', it's possible.

Below, the command is only finding files created or modified exactly 30 days ago (from -ctime 30), which is returning no files to be 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

But, if I change the -ctime to 29, it finds files:

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

sent 6657515 bytes  received 91 bytes  783247.76 bytes/sec
total size is 14039237  speedup is 2.11

What am I doing wrong? Why isn't it finding all files created/modified within the past 30 day?

1 Answer 1


Use -ctime -30. Note the -30, not just 30.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.