Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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',

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?

share|improve this question
up vote 2 down vote accepted

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

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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